[Lunr] Gravity: Add sql_returning

Review Request #735 — Created Feb. 16, 2021 and submitted

m.vanberkum
Lunr
50f6ffb...
lunr

Gravity: Add sql_returning

Wrote unit tests.
Ran unit tests.

  • 0
  • 0
  • 8
  • 0
  • 8
Description From Last Updated
pprkut
  1. 
      
  2. 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 at sql_condition() for inspiration.

    Would mean that we don't actually need a dedicated sql_returning() method after all :-/

  3. Dont forget that MariaDBDMLQueryBuilder needs changes too

  4. src/Lunr/Gravity/Database/DatabaseDMLQueryBuilder.php (Diff revision 1)
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    Nice! :D

  5. 
      
m.vanberkum
pprkut
  1. 
      
  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.

  3. $option might not be the best wording here. Since we're always constructing a statement that selects from the database, $select would be better.

    1. Since one of the funcion's parameters is also called $select that wouldn't work right?

    2. Yes, you're correct. I missed that :(

      Still not happy with $option. We can use $part instead, since we also already have the concepts of query parts matching the individual properties we store them in.

  4. 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.

  5. 
      
m.vanberkum
pprkut
  1. 
      
  2. 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.

  3. We can kill those. Remnant of early Lunr days. We don't do these kinds of dependencies anywhere else anymore :)

  4. 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.

    1. It's currently already listed like:
      Line 126: <file>../src/Lunr/Gravity/Database/Tests/DatabaseDMLQueryBuilderQueryPartsSelectTest.php</file>
      Line 127: <file>../src/Lunr/Gravity/Database/Tests/SQLDMLQueryBuilderSelectTest.php</file>

      Isn't that how its supposed to be? Or do I not understand how this works?

    2. Wrong test file :)

      The test you need to preceed is Line 117

  5. 
      
m.vanberkum
m.vanberkum
pprkut
  1. Ship It!
  2. 
      
pprkut
Review request changed

Status: Closed (submitted)

Change Summary:

Merged into master

Loading...