-
-
Since RETURNING can be followed by any kind of
select_expr
, it should support the same functionality as in sql_select().Maybe you can think of a way to share the code? :)
You can look atsql_condition()
for inspiration.Would mean that we don't actually need a dedicated
sql_returning()
method after all :-/ -
-
[Lunr] Gravity: Add sql_returning
Review Request #735 — Created Feb. 16, 2021 and submitted
Information | |
---|---|
m.vanberkum | |
Lunr | |
50f6ffb... | |
Reviewers | |
lunr | |
Gravity: Add sql_returning
Wrote unit tests.
Ran unit tests.
Change Summary:
Removed
sql_returning
& combined it withsql_select
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+72 -5) |
-
-
src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php (Diff revision 2) I prefer to keep this in line with how
sql_condition()
works, so:$base = 'SELECT'
The boolean solution isn't wrong. Using the string syntax is just more consistent with existing code.
-
src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php (Diff revision 2) $option
might not be the best wording here. Since we're always constructing a statement that selects from the database,$select
would be better. -
src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsReturningTest.php (Diff revision 2) Now that we merged the code for handling RETURNING into sql_select, you can merge the unit tests too. You can keep the separate file, just rename it to QueryPartsSelectTest and move the other tests for
sql_select()
to here too.
Change Summary:
Implemented feedback
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+145 -78) |
-
-
src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php (Diff revision 3) heh, nice initiative :)
I prefer to keep it
$select
, however.select_expr
can include columns, but also function calls, scalar values, etc. So$columns
would give the wrong impression here. -
We can kill those. Remnant of early Lunr days. We don't do these kinds of dependencies anywhere else anymore :)
-
src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php (Diff revision 3) If you change this you need to make sure that the tests you now depend on also execute before. As it's currently listed in phpunit.xml, they wouldn't.
Change Summary:
Changed variable names & removed dependencies.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+140 -77) |
Change Summary:
Changed test order
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 5 (+140 -77) |