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

not support keywords in table name, field name... #527

Open
mustlogin opened this issue May 31, 2019 · 1 comment
Open

not support keywords in table name, field name... #527

mustlogin opened this issue May 31, 2019 · 1 comment

Comments

@mustlogin
Copy link

The language of WCDB

Objective-C

The version of WCDB

pod from master, v1.0.7

The platform of WCDB

iOS

The installation of WCDB

Cocoapods

What's the issue?

WCDB doesn't support keyword. It is permitted in this doc:

https://www.sqlite.org/lang_keywords.html

With WCDB, a class as following:

@implementation Work

WCDB_IMPLEMENTATION(Work)

WCDB_SYNTHESIZE_COLUMN(Work, nid, "id")
WCDB_SYNTHESIZE(Work, proid)
WCDB_SYNTHESIZE(Work, title)
WCDB_SYNTHESIZE(Work, content)

WCDB_PRIMARY_AUTO_INCREMENT(Work, nid)
WCDB_UNIQUE_INDEX(Work, "_idx_proid", proid)

@end

If these codes are excuted:

//create table
NSString* tbName = @"work&33-cur";
b = [database createTableAndIndexesOfName:tbName withClass:Work.class];

some error output:

[WCDB][DEBUG]Code:1, Type:SQLiteGlobal, Msg:near "&": syntax error
[WCDB][ERROR]Code:1, Type:SQLite, Tag:0, Op:4, ExtCode:1, Msg:near "&": syntax error, SQL:CREATE TABLE IF NOT EXISTS work&33-cur(id INTEGER PRIMARY KEY AUTOINCREMENT,proid INTEGER,title TEXT,content TEXT), Path:/Users/xxxx/Library/Developer/CoreSimulator/Devices/654F8E8E-5EBA-41B4-B47B-88F76A0897C5/data/Containers/Data/Application/8022A5AE-B6F6-4951-A1DE-37EA4E105246/Documents/test1.db

If table name is modified :

//create table
NSString* tbName = @"[work&33-cur]";
b = [database createTableAndIndexesOfName:tbName withClass:Work.class];

the error is:

[WCDB][DEBUG]Code:1, Type:SQLiteGlobal, Msg:near "_idx_proid": syntax error
[WCDB][ERROR]Code:1, Type:SQLite, Tag:0, Op:4, ExtCode:1, Msg:near "_idx_proid": syntax error, SQL:CREATE UNIQUE INDEX IF NOT EXISTS [work&33-cur]_idx_proid ON [work&33-cur](proid), Path:/Users/xxxx/Library/Developer/CoreSimulator/Devices/654F8E8E-5EBA-41B4-B47B-88F76A0897C5/data/Containers/Data/Application/11AA5C95-2E9B-4483-9103-283B80D592A8/Documents/test1.db

But with FMDB or 3rd sqlite UI tools, following SQL is correct, the table and index will be created successfully:

//create table
CREATE TABLE IF NOT EXISTS [work&33-cur](id INTEGER PRIMARY KEY AUTOINCREMENT,proid INTEGER,title TEXT,content TEXT)
//create index
CREATE UNIQUE INDEX IF NOT EXISTS [work&33-cur_idx_prorid] ON [work&33-cur] (proid)

This problem will block our migration from FMDB to WCDB, because our some table name just like "work&33-cur".

@RingoD
Copy link
Collaborator

RingoD commented Jun 4, 2019

Well, it is a feature that we need to support.

For now, you can create the index manually(no through ORM).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants