-
Notifications
You must be signed in to change notification settings - Fork 122
Postgresql indexes #163
base: develop
Are you sure you want to change the base?
Postgresql indexes #163
Conversation
…onstraint construct. It also makes decorator creation at Platform level impossible. To avoid missing parameter and causing invalid syntaxes, will propose adding exceptions in all DB components instead of getting cryptic SQL errors in logs.
…nstruct CREATE INDEX index_name ON table_name (columns...) Intended to be used within CreateTableDecorator, but can also add it to platform if needed, as long as table name is supplied somehow.
Because AlterTable interface signature currently only takes in string, not AbstractConstraint, not able to inspect the types to determine best query to run. Modify specification to have IF EXISTS and perform operation both in ALTER TABLE and DROP INDEX DDL to account for possibility of either. Get a notice in database logs, but better than overhead and extra dependency on performing a meta query.
@alextech thanks for this PR but it will require some time to review. In the meantime, because this is a new feature, can you send againt |
Changed. |
I checked the output of by generating a CreateTable for PostgreSQL. The general syntax is nice and correct. Where it fails, is the correct escaping, if the escape character is inside column name. The table name is escaped correctly, but the indices inside and outside of CREATE TABLE are going rogue. $table = new CreateTable('t\'e"s`t');
$table->addColumn(new BigInteger('t\'e"s`tCol'))
->addColumn(new BigInteger('t\'e"s`tCol2'))
->addConstraint(new Constraint\PrimaryKey('t\'e"s`tCol'));
->addConstraint(new Index('t\'e"s`tCol2', 't\'e"s`tIndex')); Expected result: CREATE TABLE "t'e""s`t" (
"t'e""s`tCol" BIGINT NOT NULL,
"t'e""s`tCol2" BIGINT NOT NULL,
PRIMARY KEY ("t'e""s`tCol")
);
CREATE INDEX "t'e""s`tIndex" ON "t'e""s`tCol2"); Actual result: CREATE TABLE "t'e""s`t" (
"t""'""e""""""s""`""tCol" BIGINT NOT NULL,
"t""'""e""""""s""`""tCol2" BIGINT NOT NULL,
PRIMARY KEY ("t""'""e""""""s""`""tCol")
);
CREATE INDEX "t""'""e""""""s""`""tIndex" ON "t""'""e""""""s""`""t"("t""'""e""""""s""`""tCol2"); Instead of just doubling the escape character, there seems to be done some wrong and multiple escaping. This behaviour is heavily bugged for the code base, too. For this I a separate bug report #267 and perhaps we could work on a fix together for all components. |
Thanks of great magnitude giving this a test after all this time. One thing to note, to make non-MySQL tests more realistic, try to always test with schema as part of the name. There are reports of escaper not working when using semantics outlined in last comment of #206 and fixed at #232 Then, there is also #233 to consider, which fixes inconsistency in applying identifier vs identifier chain. I do not think it relates to this issue, I doubt applying it will magically fix it, but sounds familiar. Will look into it. |
Good point, but so far the Ddl doesn't seem to offer a possibility to use schema as contrary to Select syntax, where TableIdentifier receives schema as 2nd parameter. The other problem with the broken column and index names doesn't result in any of your parts but from } elseif ($type == ExpressionInterface::TYPE_IDENTIFIER) {
$values[$vIndex] = $platform->quoteIdentifierInFragment($value); I'm about to comment on this in #267. |
Revert PR zendframework#224 due to issue like zendframework#288
Thanks @rarog I will see if table identifer can be used in DDL too. |
…onstraint construct. It also makes decorator creation at Platform level impossible. To avoid missing parameter and causing invalid syntaxes, will propose adding exceptions in all DB components instead of getting cryptic SQL errors in logs.
…nstruct CREATE INDEX index_name ON table_name (columns...) Intended to be used within CreateTableDecorator, but can also add it to platform if needed, as long as table name is supplied somehow.
Because AlterTable interface signature currently only takes in string, not AbstractConstraint, not able to inspect the types to determine best query to run. Modify specification to have IF EXISTS and perform operation both in ALTER TABLE and DROP INDEX DDL to account for possibility of either. Get a notice in database logs, but better than overhead and extra dependency on performing a meta query.
…l_indexes # Conflicts: # test/Sql/Platform/PlatformTest.php
This repository has been moved to laminas/laminas-db. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
This repository has been closed and moved to laminas/laminas-db; a new issue has been opened at laminas/laminas-db#97. |
Add support for Index creation with PostgreSQL platform.
$table = CreateTable();
$table->addConstraint(new Index())
crashed with invalid syntax error. Same for AlterTable.
Can be considered as first step towards cleaning up #67
Continuing to work on finding the rest of the incompatibilities, but not sure if submit one large PR with full PgSQL support or do smaller more review manageable parts at a time. But then cannot make PRs depend on one another so, unless told otherwise will continue adding more commits here.