Insert to table with multi primary or without autoicrement primary#105
Insert to table with multi primary or without autoicrement primary#105dg merged 6 commits intonette:v2.4from ricco24:kelemen/insert-not-autoincr-primary-multi-primary
Conversation
…turns inserted record
|
Duplicate #102? |
|
Yes, it is duplicate. I noticed your PR until after I made my. So i let it here. |
|
So ... which way to go? ;-) |
6c43c50 to
6690dde
Compare
0771c2f to
425ad23
Compare
59a6661 to
b660054
Compare
5c87d56 to
d9fd67a
Compare
fa2defa to
03312a2
Compare
6ff42c6 to
d46fee7
Compare
|
@dg what with this? It is possible to merge or not? In current state nette database is unusable with php7.1, postgres 8.3+ and uuid as priamry key. Every insert fails ... |
|
May this cause a BC break? (Except that it adds new method to interface.) Or is it suitable for 2.4? |
| @@ -1,4 +1,4 @@ | |||
| /*!40102 SET storage_engine = InnoDB */; | |||
| /*!40102 SET default_storage_engine = InnoDB */; | |||
There was a problem hiding this comment.
What about CREATE TABLE ... ENGINE=InnoDB as used in other files?
src/Database/Structure.php
Outdated
| // Search for autoincrement key from multi primary key | ||
| if (is_array($primaryKey)) { | ||
| foreach ($this->getColumns($table) as $column) { | ||
| if (in_array($column['name'], $primaryKey) && $column['autoincrement']) { |
There was a problem hiding this comment.
in_array() is relative slow operation, is possible this?
if (is_array($primaryKey)) {
$keys = array_flip($primaryKey);
foreach ($this->getColumns($table) as $column) {
if (isset($keys[$column['name']]) && $column['autoincrement']) {
return $column['name'];
}
}
return NULL;
}|
What about move searching for keys from |
|
That seems to be a good idea. I can make another pr with optimized loadStructure() function when this will be merged. |
|
Ok, so I'll merge it. Thanks! 1f6133b |
Insert to table without autoincrement primary or with multiple column primary returns inserted record.
I cant find bug1342.postgre but i think this solve this bug too. Maybe i can delete this bug report test file.
fixes #41 #80