2shady4u / godot-sqlite

GDExtension wrapper for SQLite (Godot 4.x+)
MIT License
973 stars 83 forks source link

Support INDEX creation in import_from_json #191

Open majdisorder opened 1 month ago

majdisorder commented 1 month ago

Is your feature request related to a problem? Please describe.

It would be a nice addition if import_from_json had INDEX support. This will further the capabilities for users who wish to use import_from_json as a way to create a (empty) database instance.

Describe the solution you'd like

Add support for a new object with "type": "index" to import_from_json.
I guess it would also make sense to include indexes in export_to_json.

As an alternative, an "indexes": [] property could be introduced to the "type": "table" object.

Describe alternatives you've considered

It's now possible to tack on a CREATE INDEX at the end of your table's "sql" property. This is okay for single indexes but quickly becomes unreadable and unwieldy for multiple indexes or tables with many columns.

[{
    "name": "my_table", 
    "sql": "CREATE TABLE my_table (..., col_name TEXT); CREATE UNIQUE INDEX my_table_col_ix ON my_table(col_name);",
    "type": "table",
    "row_array":[]
}]