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

column names need to be quoted #342

Closed
outofculture opened this issue Jan 3, 2020 · 4 comments
Closed

column names need to be quoted #342

outofculture opened this issue Jan 3, 2020 · 4 comments

Comments

@outofculture
Copy link

For any column named the same as a sqlite keyword, e.g. "when" or "select", the generated sql needs to put quotes around the column.

@outofculture
Copy link
Author

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)
  sqflite:
    dependency: "direct main"
    description:
      name: sqflite
      url: "https://pub.dartlang.org"
    source: hosted
    version: "1.2.0"

@alextekartik
Copy link
Contributor

alextekartik commented Jan 3, 2020

Indeed, that is mentionned here https://github.com/tekartik/sqflite/blob/de1928b5ebf90e92a63cc2da2dff7518762e4eb1/sqflite/README.md#table-and-column-names

It seems you are using raw command (rawInsert) through jaguar_query_sqflite so it is up to you (or the jaguar_query_sqflite package) to escape sqlite keywords.

@outofculture
Copy link
Author

Ah, yeah, this is jaguar's fault. Thanks!

@outofculture
Copy link
Author

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

2 participants