Skip to content

Commit 6f89e35

Browse files
committed
added create parameters to include into deparser
1 parent f276b33 commit 6f89e35

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/main/java/net/sf/jsqlparser/statement/create/table/CreateTable.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class CreateTable implements Statement {
3737

3838
private Table table;
3939
private boolean unlogged = false;
40+
private List<String> createOptionsStrings;
4041
private List<String> tableOptionsStrings;
4142
private List<ColumnDefinition> columnDefinitions;
4243
private List<Index> indexes;
@@ -89,6 +90,16 @@ public void setTableOptionsStrings(List<String> list) {
8990
tableOptionsStrings = list;
9091
}
9192

93+
public List<String> getCreateOptionsStrings() {
94+
return createOptionsStrings;
95+
}
96+
97+
public void setCreateOptionsStrings(List<String> createOptionsStrings) {
98+
this.createOptionsStrings = createOptionsStrings;
99+
}
100+
101+
102+
92103
/**
93104
* A list of {@link Index}es (for example "PRIMARY KEY") of this table.<br>
94105
* Indexes created with column definitions (as in mycol INT PRIMARY KEY) are

src/main/java/net/sf/jsqlparser/util/deparser/CreateTableDeParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void deParse(CreateTable createTable) {
4747
if (createTable.isUnlogged()) {
4848
buffer.append("UNLOGGED ");
4949
}
50+
if (createTable.)
5051
buffer.append("TABLE ").append(createTable.getTable().getFullyQualifiedName());
5152
if (createTable.getSelect() != null) {
5253
buffer.append(" AS ").append(createTable.getSelect().toString());

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
204204
| <K_FETCH:"FETCH">
205205
| <K_NEXT:"NEXT">
206206
| <K_ONLY:"ONLY">
207+
| <K_COMMIT:"COMMIT">
207208
}
208209

209210
TOKEN : /* Numeric Constants */
@@ -2117,7 +2118,8 @@ CreateTable CreateTable():
21172118
Table table = null;
21182119
List columnDefinitions = new ArrayList();
21192120
List columnSpecs = null;
2120-
List tableOptions = new ArrayList();
2121+
List<String> tableOptions = new ArrayList<String>();
2122+
List<String> createOptions = new ArrayList<String>();
21212123
Token columnName;
21222124
Token tk = null;
21232125
Token tk2 = null;
@@ -2138,7 +2140,7 @@ CreateTable CreateTable():
21382140
// TODO:
21392141
// [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ]
21402142
[ <K_UNLOGGED> { createTable.setUnlogged(true); } ]
2141-
(CreateParameter())*
2143+
(parameter = CreateParameter() { createOptions.add(parameter); })*
21422144

21432145
<K_TABLE> table=Table()
21442146
[
@@ -2262,6 +2264,8 @@ CreateTable CreateTable():
22622264
createTable.setTable(table);
22632265
if (indexes.size() > 0)
22642266
createTable.setIndexes(indexes);
2267+
if (createOptions.size() > 0)
2268+
createTable.setCreateOptionsStrings(createOptions);
22652269
if (tableOptions.size() > 0)
22662270
createTable.setTableOptionsStrings(tableOptions);
22672271
if (columnDefinitions.size() > 0)
@@ -2336,6 +2340,12 @@ String CreateParameter():
23362340
|
23372341
tk=<S_DOUBLE> { retval = tk.image; }
23382342
|
2343+
tk=<K_ON> { retval = tk.image; }
2344+
|
2345+
tk=<K_COMMIT> { retval = tk.image; }
2346+
|
2347+
tk=<K_ROWS> { retval = tk.image; }
2348+
|
23392349
"=" { retval = "="; }
23402350
|
23412351
retval=AList()

0 commit comments

Comments
 (0)