v1a0 / sqllex

The most pythonic ORM (for SQLite and PostgreSQL). Seriously, try it out!
https://v1a0.github.io/sqllex
GNU General Public License v3.0
92 stars 8 forks source link

Column type issue #3

Closed v1a0 closed 3 years ago

v1a0 commented 3 years ago

Code:

def somefunc():
    template: DBTemplateType = {
        'users': {
            'id': [PRIMARY_KEY, INTEGER, NOT_NULL],
        }
    }
    db = SQLite3x(template=template)

error: sqlite3.OperationalError: near "INTEGER": syntax error

CREATE TABLE IF NOT EXISTS 'users'  (
id PRIMARY KEY INTEGER NOT NULL
) ;  

because it's awaiting

CREATE TABLE IF NOT EXISTS 'users'  (
id INTEGER PRIMARY KEY NOT NULL
) ;  
v1a0 commented 3 years ago
template: DBTemplateType = {
        'xxx': {
            'balance': [INTEGER, DEFAULT, 0],
        }
    }
db = SQLite3x(template=template)

TypeError: sequence item 2: expected str instance, int found


Passed only if value str

'balance': [INTEGER, DEFAULT, '0'],
v1a0 commented 3 years ago

Accepted since Sqllex version 0.1.6.5