lessql icon indicating copy to clipboard operation
lessql copied to clipboard

Consistent function naming

Open shadowhand opened this issue 10 years ago • 3 comments

There is an odd mix of snake_case (table_name, etc) and camelCase (fetchAll, nameList, etc) going on in the code.

shadowhand avatar May 21 '15 04:05 shadowhand

Everything is camelCase except for table names. SQL is case-insensitive and most schemas are snake_case. The table name in $db->table_name() is a shorthand for $db->table( 'table_name' ) and directly represents the schema, that's why it's in snake_case, too. It might be beneficial to have automatic camelCase to snake_case conversion; currently you could do that with a rewrite function, see the Database/setRewrite method.

morris avatar May 21 '15 08:05 morris

When using Database::setRewrite method to achieve this behavior i get strange error when back-referenced table names do not pass through this method and not converted to proper format. When you try to get back-referenced table, foreigh keys do not get converted.

P.S. It could be great if we could have some kind of settings to enable camelCase behavior by default for all fields and tables.

P.P.S. @morris You are doing a great job to continue NotORM style DB access in more modern way. Thank you!

ilsenem avatar Apr 19 '16 04:04 ilsenem

Hey ilsenem, thanks for your kind words! Would you mind opening a separate issue describing how to reproduce the behavior you're experiencing with setRewrite? 🍻

morris avatar Apr 19 '16 21:04 morris