Skip to content

Commit 7f84ccd

Browse files
authored
Merge pull request #6 from etemplar/autoincrementpk
Autoincrement field addition.
2 parents 984c849 + 3373da8 commit 7f84ccd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sqliteparser/src/main/java/com/vansuita/sqliteparser/Create.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ public Create pk(String fieldName) {
4848
return this;
4949
}
5050

51+
/**
52+
* Sets the primary key autoincrement field name.
53+
*
54+
* @param fieldName The name of the field
55+
* @return the same instance of {@link Create} class.
56+
*/
57+
public Create pkai(String fieldName) {
58+
fields.put(fieldName, AUTOINCREMENT);
59+
return this;
60+
}
61+
5162
/**
5263
* Sets a String field name.
5364
*

sqliteparser/src/main/java/com/vansuita/sqliteparser/SqlParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public String build() {
6464
protected static final String CREATE_TABLE = "CREATE TABLE %s (%s)";
6565
protected static final String INTEGER = "INTEGER";
6666
protected static final String PK = INTEGER + " PRIMARY KEY";
67+
protected static final String AUTOINCREMENT = PK + " AUTOINCREMENT";
6768
protected static final String TEXT = "TEXT";
6869
protected static final String FLOAT = "FLOAT";
6970

0 commit comments

Comments
 (0)