Skip to content

Commit

Permalink
Merge pull request mevdschee#82 from ferambot/master
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
mevdschee authored Jun 12, 2016
2 parents 81e0123 + 11fa7c8 commit 01208ba
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ Search is implemented with the "filter" parameter. You need to specify the colum
- le: lower or equal (number is lower than or equal to value)
- ge: greater or equal (number is higher than or equal to value)
- gt: greater than (number is higher than value)
- in: in (number is in comma seperated list of values)
- ni: not in (number is not in comma seperated list of values)
- in: in (number is in comma separated list of values)
- ni: not in (number is not in comma separated list of values)
- is: is null (field contains "NULL" value)
- no: not null (field does not contain "NULL" value)

Expand Down Expand Up @@ -186,7 +186,7 @@ Output:

### List + Column selection

By default all columns are selected. With the "columns" parameter you can select specific columns. Multiple columns should be comma seperated. An asterisk ("*") may be used as a wildcard to indicate "all columns":
By default all columns are selected. With the "columns" parameter you can select specific columns. Multiple columns should be comma separated. An asterisk ("*") may be used as a wildcard to indicate "all columns":

```
GET http://localhost/api.php/categories?columns=name
Expand Down
2 changes: 1 addition & 1 deletion extras/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$sql = "delete `$table` where id=$key"; break;
}

// excecute SQL statement
// execute SQL statement
$result = mysqli_query($link,$sql);

// die if SQL statement failed
Expand Down
2 changes: 1 addition & 1 deletion tests/blog_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CREATE TABLE `categories` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

INSERT INTO `categories` (`id`, `name`, `icon`) VALUES
(1, 'anouncement', NULL),
(1, 'announcement', NULL),
(2, 'article', NULL);

DROP TABLE IF EXISTS `comments`;
Expand Down
2 changes: 1 addition & 1 deletion tests/blog_postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ CREATE TABLE users (
--

INSERT INTO "categories" ("name", "icon") VALUES
('anouncement', NULL),
('announcement', NULL),
('article', NULL);

--
Expand Down
2 changes: 1 addition & 1 deletion tests/blog_sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ CREATE TABLE "categories" (
"icon" blob NULL
);

INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'anouncement', NULL);
INSERT INTO "categories" ("id", "name", "icon") VALUES (1, 'announcement', NULL);
INSERT INTO "categories" ("id", "name", "icon") VALUES (2, 'article', NULL);

DROP TABLE IF EXISTS "comments";
Expand Down
2 changes: 1 addition & 1 deletion tests/blog_sqlserver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ CREATE TABLE [users](
GO
SET IDENTITY_INSERT [categories] ON
GO
INSERT [categories] ([id], [name], [icon]) VALUES (1, N'anouncement', NULL)
INSERT [categories] ([id], [name], [icon]) VALUES (1, N'announcement', NULL)
GO
INSERT [categories] ([id], [name], [icon]) VALUES (2, N'article', NULL)
GO
Expand Down
8 changes: 4 additions & 4 deletions tests/tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ public function testListExampleFromReadme()
{
$test = new API($this);
$test->get('/posts?include=categories,tags,comments&filter=id,eq,1');
$test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[["1","1","1","blog started"]]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[["1","1","1"],["2","1","2"]]},"categories":{"relations":{"id":"posts.category_id"},"columns":["id","name","icon"],"records":[["1","anouncement",null]]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[["1","funny"],["2","important"]]},"comments":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","message"],"records":[["1","1","great"],["2","1","fantastic"]]}}');
$test->expect('{"posts":{"columns":["id","user_id","category_id","content"],"records":[["1","1","1","blog started"]]},"post_tags":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","tag_id"],"records":[["1","1","1"],["2","1","2"]]},"categories":{"relations":{"id":"posts.category_id"},"columns":["id","name","icon"],"records":[["1","announcement",null]]},"tags":{"relations":{"id":"post_tags.tag_id"},"columns":["id","name"],"records":[["1","funny"],["2","important"]]},"comments":{"relations":{"post_id":"posts.id"},"columns":["id","post_id","message"],"records":[["1","1","great"],["2","1","fantastic"]]}}');
}

public function testListExampleFromReadmeWithTransform()
{
$test = new API($this);
$test->get('/posts?include=categories,tags,comments&filter=id,eq,1&transform=1');
$test->expect('{"posts":[{"id":"1","post_tags":[{"id":"1","post_id":"1","tag_id":"1","tags":[{"id":"1","name":"funny"}]},{"id":"2","post_id":"1","tag_id":"2","tags":[{"id":"2","name":"important"}]}],"comments":[{"id":"1","post_id":"1","message":"great"},{"id":"2","post_id":"1","message":"fantastic"}],"user_id":"1","category_id":"1","categories":[{"id":"1","name":"anouncement","icon":null}],"content":"blog started"}]}');
$test->expect('{"posts":[{"id":"1","post_tags":[{"id":"1","post_id":"1","tag_id":"1","tags":[{"id":"1","name":"funny"}]},{"id":"2","post_id":"1","tag_id":"2","tags":[{"id":"2","name":"important"}]}],"comments":[{"id":"1","post_id":"1","message":"great"},{"id":"2","post_id":"1","message":"fantastic"}],"user_id":"1","category_id":"1","categories":[{"id":"1","name":"announcement","icon":null}],"content":"blog started"}]}');
}

public function testEditCategoryWithBinaryContent()
Expand Down Expand Up @@ -487,7 +487,7 @@ public function testFilterCategoryOnNullIcon()
{
$test = new API($this);
$test->get('/categories?filter[]=icon,is,null&transform=1');
$test->expect('{"categories":[{"id":"1","name":"anouncement","icon":null},{"id":"2","name":"alert();","icon":null}]}');
$test->expect('{"categories":[{"id":"1","name":"announcement","icon":null},{"id":"2","name":"alert();","icon":null}]}');
}

public function testFilterCategoryOnNotNullIcon()
Expand Down Expand Up @@ -522,7 +522,7 @@ public function testColumnsOnInclude()
{
$test = new API($this);
$test->get('/posts?include=categories&columns=categories.name&filter=id,eq,1&transform=1');
$test->expect('{"posts":[{"category_id":"1","categories":[{"id":"1","name":"anouncement"}]}]}');
$test->expect('{"posts":[{"category_id":"1","categories":[{"id":"1","name":"announcement"}]}]}');
}

public function testColumnsOnWrongInclude()
Expand Down

0 comments on commit 01208ba

Please sign in to comment.