Skip to content

CREATE TABLE - default-values on columns #1022

@gitmotte

Description

@gitmotte
   CREATE TABLE myschema.tableName (
                id bigint NOT NULL DEFAULT nextval('myschema.mysequence'::regclass), 
                bool_col boolean NOT NULL DEFAULT false, 
                int_col integer NOT NULL DEFAULT 0)

Default-Values not supported currently

  • boolean (true|false)
  • nextval (postgresql syntax)
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "nextval" "NEXTVAL"
    at line 1, column 61.

Was expecting one of:

    "("
    ")"
    "+"
    ","
    "-"
    "::"
    "="
    "ASC"
    "BY"
    "CASCADE"
    "CHECK"
    "COLLATE"
    "COMMENT"
    "COMMIT"
    "CONSTRAINT"
    "DEFAULT"
    "DELETE"
    "DESC"
    "EXCLUDE"
    "FOREIGN"
    "IN"
    "KEY"
    "NOT"
    "NULL"
    "ON"
    "PARTITION"
    "PRIMARY"
    "REFERENCES"
    "ROWS"
    "TABLESPACE"
    "TEMP"
    "TEMPORARY"
    "TYPE"
    "UNIQUE"
    "UNSIGNED"
    "UPDATE"
    "USING"
    "WHERE"
    "WITH"
    <K_TIME_KEY_EXPR>
    <S_CHAR_LITERAL>
    <S_DOUBLE>
    <S_IDENTIFIER>
    <S_LONG>
    <S_QUOTED_IDENTIFIER>

	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:165)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:59)
	at net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed(TestUtils.java:88)
	at net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed(TestUtils.java:74)
	at net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed(TestUtils.java:59)
	at net.sf.jsqlparser.statement.create.CreateTableTest.testCreateTableWithDefault(CreateTableTest.java:677)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)
Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "nextval" "NEXTVAL"
    at line 1, column 61.

Was expecting one of:

    "("
    ")"
    "+"
    ","
    "-"
    "::"
    "="
    "ASC"
    "BY"
    "CASCADE"
    "CHECK"
    "COLLATE"
    "COMMENT"
    "COMMIT"
    "CONSTRAINT"
    "DEFAULT"
    "DELETE"
    "DESC"
    "EXCLUDE"
    "FOREIGN"
    "IN"
    "KEY"
    "NOT"
    "NULL"
    "ON"
    "PARTITION"
    "PRIMARY"
    "REFERENCES"
    "ROWS"
    "TABLESPACE"
    "TEMP"
    "TEMPORARY"
    "TYPE"
    "UNIQUE"
    "UNSIGNED"
    "UPDATE"
    "USING"
    "WHERE"
    "WITH"
    <K_TIME_KEY_EXPR>
    <S_CHAR_LITERAL>
    <S_DOUBLE>
    <S_IDENTIFIER>
    <S_LONG>
    <S_QUOTED_IDENTIFIER>

	at net.sf.jsqlparser.parser.CCJSqlParser.generateParseException(CCJSqlParser.java:25083)
	at net.sf.jsqlparser.parser.CCJSqlParser.jj_consume_token(CCJSqlParser.java:24927)
	at net.sf.jsqlparser.parser.CCJSqlParser.CreateTable(CCJSqlParser.java:13665)
	at net.sf.jsqlparser.parser.CCJSqlParser.SingleStatement(CCJSqlParser.java:175)
	at net.sf.jsqlparser.parser.CCJSqlParser.Statement(CCJSqlParser.java:79)
	at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:163)
	... 28 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions