You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test('basic count aggregation', function () use ($explorer) {
21
21
$count = $explorer->table('book')->count('*'); // SELECT COUNT(*) FROM `book`
22
22
Assert::same(4, $count);
23
23
});
24
24
25
25
26
-
test('', function () use ($explorer) {
26
+
test('related count aggregation', function () use ($explorer) {
27
27
$tags = [];
28
28
foreach ($explorer->table('book') as$book) { // SELECT * FROM `book`
29
29
$count = $book->related('book_tag')->count('*'); // SELECT COUNT(*), `book_id` FROM `book_tag` WHERE (`book_tag`.`book_id` IN (1, 2, 3, 4)) GROUP BY `book_id`
@@ -39,21 +39,21 @@ test('', function () use ($explorer) {
39
39
});
40
40
41
41
42
-
test('', function () use ($explorer) {
42
+
test('group by with join condition', function () use ($explorer) {
43
43
$authors = $explorer->table('author')->where(':book.translator_id IS NOT NULL')->group('author.id'); // SELECT `author`.* FROM `author` INNER JOIN `book` ON `author`.`id` = `book`.`author_id` WHERE (`book`.`translator_id` IS NOT NULL) GROUP BY `author`.`id`
44
44
Assert::count(2, $authors);
45
45
Assert::same(2, $authors->count('DISTINCT author.id')); // SELECT COUNT(DISTINCT author.id) FROM `author` INNER JOIN `book` ON `author`.`id` = `book`.`author_id` WHERE (`book`.`translator_id` IS NOT NULL)
46
46
});
47
47
48
48
49
-
test('', function () use ($explorer) {
49
+
test('having clause with group by', function () use ($explorer) {
50
50
$authors = $explorer->table('book')->group('book.id')->having('COUNT(DISTINCT :book_tag.tag_id) < 2'); // SELECT `author`.* FROM `author` INNER JOIN `book` ON `author`.`id` = `book`.`author_id` WHERE (`book`.`translator_id` IS NOT NULL) GROUP BY `author`.`id`
51
51
Assert::count(2, $authors);
52
52
Assert::same(2, $authors->count('DISTINCT author.id')); // SELECT COUNT(DISTINCT author.id) FROM `author` INNER JOIN `book` ON `author`.`id` = `book`.`author_id` WHERE (`book`.`translator_id` IS NOT NULL)
53
53
});
54
54
55
55
56
-
test('', function () use ($explorer) {
56
+
test('distinct count in related aggregation', function () use ($explorer) {
57
57
$bookTags = [];
58
58
foreach ($explorer->table('book') as$book) {
59
59
$book_tags = $book->related('book_tag');
@@ -69,7 +69,7 @@ test('', function () use ($explorer) {
69
69
});
70
70
71
71
72
-
test('', function () use ($explorer) {
72
+
test('filtering groups by related count', function () use ($explorer) {
test('join with order by related column', function () use ($explorer) {
23
23
$apps = [];
24
24
foreach ($explorer->table('book')->order('author.name, title') as$book) { // SELECT `book`.* FROM `book` LEFT JOIN `author` ON `book`.`author_id` = `author`.`id` ORDER BY `author`.`name`, `title`
25
25
$apps[$book->title] = $book->author->name; // SELECT * FROM `author` WHERE (`author`.`id` IN (12, 11))
@@ -34,7 +34,7 @@ test('', function () use ($explorer) {
34
34
});
35
35
36
36
37
-
test('', function () use ($explorer, $driver) {
37
+
test('join SQL structure verification', function () use ($explorer, $driver) {
if ($driver->isSupported(Driver::SupportSchema)) {
@@ -68,7 +68,7 @@ test('', function () use ($explorer, $driver) {
68
68
});
69
69
70
70
71
-
test('', function () use ($explorer) {
71
+
test('multi-table join with group by', function () use ($explorer) {
72
72
$tags = [];
73
73
foreach ($explorer->table('book_tag')->where('book.author.name', 'Jakub Vrana')->group('book_tag.tag_id')->order('book_tag.tag_id') as$book_tag) { // SELECT `book_tag`.* FROM `book_tag` INNER JOIN `book` ON `book_tag`.`book_id` = `book`.`id` INNER JOIN `author` ON `book`.`author_id` = `author`.`id` WHERE (`author`.`name` = ?) GROUP BY `book_tag`.`tag_id`
74
74
$tags[] = $book_tag->tag->name; // SELECT * FROM `tag` WHERE (`tag`.`id` IN (21, 22, 23))
@@ -82,12 +82,12 @@ test('', function () use ($explorer) {
82
82
});
83
83
84
84
85
-
test('', function () use ($explorer) {
85
+
test('count through joined table', function () use ($explorer) {
86
86
Assert::same(2, $explorer->table('author')->where('author_id', 11)->count(':book.id')); // SELECT COUNT(book.id) FROM `author` LEFT JOIN `book` ON `author`.`id` = `book`.`author_id` WHERE (`author_id` = 11)
87
87
});
88
88
89
89
90
-
test('', function () use ($explorer) {
90
+
test('multiple column selection from joins', function () use ($explorer) {
0 commit comments