forked from mozilla/moz-sql-parser
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from megh-khaire/dev
Support autoincrement clause for sqlite
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# encoding: utf-8 | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
|
||
|
||
from unittest import TestCase | ||
from mo_sql_parsing import parse | ||
|
||
|
||
class TestSqlite(TestCase): | ||
def test_autoincrement_in_create(self): | ||
sql = """ | ||
CREATE TABLE Products ( | ||
product_id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
name TEXT NOT NULL, | ||
price REAL NOT NULL, | ||
description TEXT | ||
); | ||
""" | ||
result = parse(sql) | ||
|
||
self.assertEqual( | ||
result, | ||
{ | ||
'create table': { | ||
'name': 'Products', | ||
'columns': [ | ||
{'name': 'product_id', 'type': {'integer': {}}, 'primary_key': True, 'autoincrement': True}, | ||
{'name': 'name', 'type': {'text': {}}, 'nullable': False}, | ||
{'name': 'price', 'type': {'real': {}}, 'nullable': False}, | ||
{'name': 'description', 'type': {'text': {}}} | ||
] | ||
} | ||
}, | ||
) |