|
@@ -7,10 +7,19 @@
|
7
|
7
|
# define create, drop and alter Query to manipulate tables
|
8
|
8
|
# define create_user, delete_user and grant to manipulate user and rights
|
9
|
9
|
|
10
|
|
-from mosql.util import Clause, Statement, Query, value, identifier, concat_by_comma, paren
|
|
10
|
+from mosql.util import Clause, Statement, Query, value, identifier, concat_by_comma, paren, raw
|
|
11
|
+
|
|
12
|
+def col_def(cols):
|
|
13
|
+ print("cols", cols)
|
|
14
|
+ ret = []
|
|
15
|
+ for col in cols:
|
|
16
|
+ print("col", col)
|
|
17
|
+ name, definition = col
|
|
18
|
+ ret.append(identifier(name) + ' ' + raw(definition))
|
|
19
|
+ return ret
|
11
|
20
|
|
12
|
21
|
# chain definitions
|
13
|
|
-column_list = (identifier, concat_by_comma, paren)
|
|
22
|
+column_list = (col_def, concat_by_comma, paren)
|
14
|
23
|
|
15
|
24
|
# Clauses
|
16
|
25
|
create_clause = Clause('create table', alias='create', no_argument=True)
|
|
@@ -20,7 +29,7 @@ character_clause = Clause('CHARACTER SET', (value, ), alias='character')
|
20
|
29
|
column_clause = Clause('column', column_list, alias='column', hidden=True)
|
21
|
30
|
|
22
|
31
|
alter_clause = Clause('alter table', (identifier, ), alias='table')
|
23
|
|
-add_clause = Clause('add column', (identifier, ), alias='column')
|
|
32
|
+add_clause = Clause('add column', (col_def, ), alias='column')
|
24
|
33
|
|
25
|
34
|
# Statements
|
26
|
35
|
create_statement = Statement([create_clause, if_not_exists, table_clause, column_clause, character_clause])
|