Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Issue link: http://drupal.org/node/224333#dbtng
Comment | File | Size | Author |
---|---|---|---|
#19 | coder_upgrade.db_.inc_.19.txt | 13.12 KB | duellj |
#18 | coder_upgrade.db_.inc_.18.txt | 12.14 KB | duellj |
#17 | coder_upgrade.db_.inc_.17.txt | 14.13 KB | duellj |
#10 | coder_upgrade.db_.inc_.txt | 18.14 KB | solotandem |
#9 | cu-643008-dbtng.patch | 9.03 KB | solotandem |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commenteder, this seems critical.
Comment #2
solotandem CreditAttribution: solotandem commentedStarted in next dev release.
Comment #3
duellj CreditAttribution: duellj commentedI've started on making this work. This patch just includes updates to db_query("SELECT...") that rewrites conditions. So far it rewrites "field = %x" and "field IN('%s')" conditions. What are the other conditions we need to handle?
Comment #4
duellj CreditAttribution: duellj commentedThis patch beings the work for handling more complex conditional statements. So far it doesn't handle nested conditionals or anything other than AND operators, but it's a start, and should handle a good percentage of the upgrade cases. I'll continue working it to see if I can get those issues included.
Comment #5
adrian CreditAttribution: adrian commentedI just reviewed and updated this a bit.
it now handles string / numeric literals for both conditions and assignment in insert statements.
http://github.com/Vertice/coder/commit/fb846eb9a77210bd515ba6d6f903ef027...
the patch is on there.
Comment #6
duellj CreditAttribution: duellj commentedI think there's still some work that needs to happen with this. For coder_upgrade_parser_sql_conditions, I think we can skip nested conditionals for now, but it's important to be able to handle AND, OR, and XOR operators.
There was an error with how literals were being handle in select statements, this patch fixes it.
Comment #7
duellj CreditAttribution: duellj commentedJust noticed this, too (thanks crell):
http://api.drupal.org/api/group/node_access/7
So if a select query is in the form of "SELECT ... FROM {node}..." then it should be rewritten into a dynamic query with the tag "node_access".
Comment #8
BerdirHaven't read the patch in detail, just a few things to think about. I guess not all of these can be handled automatically...
- Actually, we should check on db_rewrite_sql instead of SELECT .... FROM {node} since there are also other tags (term_access, ....)
- Also, all INSERT/DELETE/UPDATE statements need to be updated to use db_insert()/db_delete()/db_update()
- "while ($row = db_fetch_object($result)) { " became "foreach ($result as $row) {" (and db_fetch_array() needs to set the fetch mode)
- "db_result(db_query())" became "db_query()->fetchField()"
- pager_query() and tablesort_sql() are gone, the query needs to be converted into a dynamic select query and extended with PagerDefault/Tablesort
- hook_db_rewrite_sql() is obviously gone too
- ...
Comment #9
solotandem CreditAttribution: solotandem commentedAttached update to patch in #6. Handles 1) string literals with spaces, 2) sql string spanning multiple lines. I reordered one function and the regex on the select statement conditions (it puts the %s and 'x' types together followed by IN which is different).
Comment #10
solotandem CreditAttribution: solotandem commentedJon, try out this code before I commit it.
Also need to change insertListBefore() in parser.list.inc (2 occurrences of $type2):
while ($node->next != NULL) {
$type2 = is_null($type) ? $node->type : $type; // TODO Would seem to be preferable to always use type from the node being inserted.
$data = $node->data;
$this->insertBefore($current, $data, $type2);
$node = &$node->next;
}
Comment #11
duellj CreditAttribution: duellj commentedFound another db_query() that fails:
is translated to:
Comment #12
ctmattice1 CreditAttribution: ctmattice1 commentedQuestion?
In the upgrade process what about older update_hook_N(). I ran todays CVS of coder and found
this was on a quotes_update_6014. shouldn't upgrade ignore the update_sql function as it does with db_schema translations
Comment #13
solotandem CreditAttribution: solotandem commentedThe purpose of this upgrade routine was to remove references to update_sql as it no longer exists in D7. What do you mean by "db_schema translations?"
Comment #14
ctmattice1 CreditAttribution: ctmattice1 commented@solotandem: the t() function on description
here's a section
from what I can tell, upgrader leaves everything in update_hook_N() as it should except for removing update_sql(). Since 6 is going to be around for a while think it should be left in.
Comment #15
ctmattice1 CreditAttribution: ctmattice1 commentedUmmm,
Nevermind, I'm Brain Dead. For some reason I was thinking leaving 6x functions in 7x version.
Pure stupidity on me.
Comment #16
ctmattice1 CreditAttribution: ctmattice1 commentedoops, didn't mead to change status
Comment #17
duellj CreditAttribution: duellj commentedI've been working getting database conversions integrated with SqlParser (http://drupal.org/project/sql_parser), and wanted to post up my progress. Currently this only converts insert/update/delete commands into DBTNG statements using SqlParser. Work still needs to be done to properly convert select commands using SqlParser.
Comment #18
duellj CreditAttribution: duellj commentedHere's an updated version that implements string to string parsing and converting for select commands. There's still some bugs within sql_parser (if you find any more, please post new issues there), but it seem to be working fairly well.
Solotandem, let me know if I'm going in the right direction and what you think of sql_parser.
Comment #19
duellj CreditAttribution: duellj commentedAnother reroll to keep up with the changes happening in sql_parser. This adds proper error handling so coder_upgrade doesn't blow up if an error is found when parsing a sql statement.
Comment #20
Anonymous (not verified) CreditAttribution: Anonymous commentedIs there a patch that can be applied to the module to get this to work? It seems like I would need to apply a patch and include the file that duellj is working on. Also, the directory structure in the latest patch keeps the patch from applying.
Comment #21
NROTC_Webmaster CreditAttribution: NROTC_Webmaster commentedThis module has been a huge help but it did miss the db_fetch_array() call. I think linking it to the documentation or a refence to the data in post 8 would be great.
Comment #22
klausiCoder 7.x-1.x is frozen now and will not receive any updates. Coder 8.x-2.x can be used to check code for any Drupal version, Coder 8.x-2.x also supports the phpcbf command to automatically fix conding standard errors. Please check if this issue is still relevant and reopen against that version if necessary.