Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqfliteAdapter needs to quote column names #176

Open
outofculture opened this issue Jan 8, 2020 · 0 comments
Open

SqfliteAdapter needs to quote column names #176

outofculture opened this issue Jan 8, 2020 · 0 comments

Comments

@outofculture
Copy link

Column names can, in theory, be the same as sqlite keywords, so long as they are always surrounded in double-quotes in the generated sql. SqlBuilder from package:sqflite/src/sql_builder.dart already does this, so it might be enough to reimplement all the different compose functions as just calls to their respective SqlBuilder methods, e.g. composeInsert becomes return SqlBuilder.insert(info.table, info.values);.

For reference, here's the error for a column named "when":

E/flutter ( 5937): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: DatabaseException(near "when": syntax error (code 1 SQLITE_ERROR): , while compiling: INSERT INTO flashcards_app_scoringevent(id, student_id, session_id, card_id, deck_id, already_posted, when, event_type) VALUES ('d96c2f46-fd39-44d1-876f-a6c869b9d225', '8c4240b4-76b2-49c0-aaef-842ab56e8f42', 'aef58415-0278-4055-9b33-eb582df91321', 'dfad7192-406e-473b-b06f-f1396e9f5594', '76ff7659-a578-4ed7-b7c5-11d8cf5f38e7', 1, "2020-01-03 13:03:38.219615", 'correct')) sql 'INSERT INTO flashcards_app_scoringevent(id, student_id, session_id, card_id, deck_id, already_posted, when, event_type) VALUES ('d96c2f46-fd39-44d1-876f-a6c869b9d225', '8c4240b4-76b2-49c0-aaef-842ab56e8f42', 'aef58415-0278-4055-9b33-eb582df91321', 'dfad7192-406e-473b-b06f-f1396e9f5594', '76ff7659-a578-4ed7-b7c5-11d8cf5f38e7', 1, "2020-01-03 13:03:38.219615", 'correct')' args []}
E/flutter ( 5937): #0      wrapDatabaseException (package:sqflite/src/exception_impl.dart:12:7)
E/flutter ( 5937): <asynchronous suspension>
E/flutter ( 5937): #1      SqfliteDatabaseFactoryImpl.wrapDatabaseException (package:sqflite/src/factory_impl.dart:25:7)
E/flutter ( 5937): #2      SqfliteDatabaseMixin.safeInvokeMethod (package:sqflite/src/database_mixin.dart:188:15)
E/flutter ( 5937): #3      SqfliteDatabaseMixin.txnRawInsert.<anonymous closure> (package:sqflite/src/database_mixin.dart:363:14)
E/flutter ( 5937): #4      SqfliteDatabaseMixin.txnSynchronized.<anonymous closure> (package:sqflite/src/database_mixin.dart:307:22)
E/flutter ( 5937): #5      BasicLock.synchronized (package:synchronized/src/basic_lock.dart:32:26)
E/flutter ( 5937): #6      SqfliteDatabaseMixin.txnSynchronized (package:sqflite/src/database_mixin.dart:303:43)
E/flutter ( 5937): #7      SqfliteDatabaseMixin.txnWriteSynchronized (package:sqflite/src/database_mixin.dart:325:7)
E/flutter ( 5937): #8      SqfliteDatabaseMixin.txnRawInsert (package:sqflite/src/database_mixin.dart:362:12)
E/flutter ( 5937): #9      SqfliteDatabaseExecutorMixin.rawInsert (package:sqflite/src/database_mixin.dart:49:15)
E/flutter ( 5937): #10     SqfliteAdapter.insert (package:jaguar_query_sqflite/src/adapter.dart:62:23)

(plus 30 other frames that are just flutter)

  sqflite:
    dependency: "direct main"
    description:
      name: sqflite
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.0"
  jaguar_orm:
    dependency: "direct main"
    description:
      name: jaguar_orm
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.7"
  jaguar_orm_gen:
    dependency: "direct dev"
    description:
      name: jaguar_orm_gen
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.30"
  jaguar_query:
    dependency: transitive
    description:
      name: jaguar_query
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.9"
  jaguar_query_sqflite:
    dependency: "direct main"
    description:
      name: jaguar_query_sqflite
      url: "https://pub.dartlang.org"
    source: hosted
    version: "2.2.11"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant