-
Notifications
You must be signed in to change notification settings - Fork 168
Database programming guidelines #3805
Comments
999 as per sqlite |
minus other conditions. so if you have |
MySQL / InnoDB indexes are limited to 767 bytes - which is 191 char max for |
string concatenation |
Thanks for all the information, folks. I'll get the docs updated. |
Is this documentation to be updated, or is a new section required? |
Sounds good, let's add it there maybe before all the code ? |
Added "- always add the table name when calling |
So to sum up, @PVince81 you want something along those lines?
and this should be added here: |
@voroyam yes, would be great. Maybe it should rather appear after "Database Access" since accessing is the first step. Then we go into details about guidelines. Is this something you'd like to put in yourself ? |
If no one else will - I could. I'd rather let a developer or engineer write the documentation for developers because of my lack of knowledge. But the chances of that are close to zero :) You, @DeepDiver1975 @VicDeo made the effort to write up the guidelines in this issue, so I thought if I just copy paste them and adjust the formatting, it would be fine. What do you think? @PVince81 |
It should be possible to plan for someone to put it in, if everyone agrees that the guidelines as they are here make sense. |
use IQueryBuilder::createPositionalParameter instead of IQueryBuilder::createNamedParameter when using like() |
@voroyam, are you implementing this? Or has it already been done? |
No, but I will. |
Question Are those both statements correct?
|
This is the collection of guidelines for database work. futher information can be found here owncloud-archive/documentation#3805
@voroyam let's make that a "999 minus number of other parameters", in a single statement, for SQLite (instead of two statements) |
Those two lines in one line?
in
|
@voroyam sounds good |
@PVince81 done |
PR merged, closing |
always use the Query Builder
use IQueryBuilder::createPositionalParameter instead of IQueryBuilder::createNamedParameter when using like()
don't update more than 1 million rows within a transaction due to DB limitations
don't add more than 1000 conditions in a WHERE ... IN ... statement but chunk it into separate queries
when processing big tables, always do this in chunks, don't store the whole table in memory
Oracle compatibility specifics:
createFunction
. the escaping is usually done automatically by the query builder otherwise. Oracle is the most likely to complain about unquoted columns while other databases will work finealways add the table name when calling
lastInsertId($tableName)
, it is required by Oracle to return correct valuesin general don't specify a value for autoincrement column. if you have to, keep in mind that Oracle's autoincrement trigger will get in the way on INSERT, so you'll need a subsequent UPDATE to properly adjust the value
always make sure there are unit tests for the database operations with queries to verify the result, this will help find out whether the database related code works on all databases and often times might reveal database quirks
running unit tests with specific databases:
make test-php TEST_PHP_SUITE=path/to/test/file.php TEST_DATABASE=$databasetype
where "$databasetype" is one of "sqlite", "mysql", "mariadb", "pgsql", "oci" and "mysqlmb4"TODO: add more detail to all these
The text was updated successfully, but these errors were encountered: