record-macros icon indicating copy to clipboard operation
record-macros copied to clipboard

Added: TableCreate sql index generation

Open ProPuke opened this issue 7 years ago • 6 comments

TableCreate now also generates indexes when creating tables, and primary keys are added in SQLite (this was disabled before for some reason)

ProPuke avatar Aug 28 '18 04:08 ProPuke

record-macros is often used with dbadmin. Dbadmin allows to add indexes from the web interface

bablukid avatar Aug 28 '18 07:08 bablukid

How does that relate to this pull request?

ProPuke avatar Aug 28 '18 07:08 ProPuke

you said "this was disabled before for some reason", the explaination could be that the initial developer and its team (Nicolas Cannasse and Motion Twin) used it always with dbadmin. This allowed to create tables first and add indexes later through dbadmin.

bablukid avatar Aug 28 '18 08:08 bablukid

Ahh, no - It was only disabled in the case of SQLite. TableCreate had likely not been tested fully with SQLite so it was disabled there.

ProPuke avatar Sep 09 '18 17:09 ProPuke

This fails the MySQL unit tests:

CREATE TABLE MySpodClass (theId INTEGER AUTO_INCREMENT NOT NULL,`int` INTEGER NOT NULL,`double` DOUBLE NOT NULL,boolean TINYINT(1) NOT NULL,string VARCHAR(255) NOT NULL,date DATETIME NOT NULL,`binary` MEDIUMBLOB NOT NULL,abstractType MEDIUMTEXT NOT NULL,nullInt INTEGER,enumFlags INTEGER NOT NULL,data MEDIUMBLOB NOT NULL,anEnum TINYINT UNSIGNED NOT NULL,bytes BINARY(2) NOT NULL,rid INTEGER NOT NULL,rnid INTEGER,spid INTEGER)
Incorrect table definition; there can be only one auto column and it must be defined as a key

Possibly related to the absence of an index on that table and the change to:

if( !hasID )
        decls.push("PRIMARY KEY ("+Lambda.map(infos.key,quote).join(",")+")");

jonasmalacofilho avatar Nov 12 '19 00:11 jonasmalacofilho

This PR is a very useful one. I recommand we make the above suggested change, and if it passes the tests pull the commits :)

grepsuzette avatar Mar 19 '20 02:03 grepsuzette