Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgres smallint syntax error #1015

Closed
jong82 opened this issue Mar 4, 2020 · 6 comments
Closed

Postgres smallint syntax error #1015

jong82 opened this issue Mar 4, 2020 · 6 comments

Comments

@jong82
Copy link

jong82 commented Mar 4, 2020

Describe the bug
Creating a smallint column in postgres incorrectly specifies the length as smallint(5) which generates a syntax error. It just needs to be smallint.

To Reproduce
Steps to reproduce the behavior:
liquibase generateChangeLog against a database that has a smallint column.
liquibase update against an empty database to recreate the schema.

Expected behavior
Create a smallint without error

Screenshots
Unexpected error running Liquibase: ERROR: syntax error at or near "("
Position: 268 [Failed SQL: (0) CREATE TABLE public.xyz (.....SMALLINT(5)....)

Additional context
This was run inside the published docker container although that should be irrelevant for this error.

@datical-jenkins datical-jenkins changed the title Postgres smallint syntax error LB-128 ⁃ Postgres smallint syntax error Mar 4, 2020
@datical-jenkins datical-jenkins changed the title LB-128 ⁃ Postgres smallint syntax error Postgres smallint syntax error Mar 5, 2020
@jong82
Copy link
Author

jong82 commented Mar 5, 2020

It looks like an else statement was removed in the latest change to this file.
b0564c9#diff-bc6f31d07274d640e9ce14961f99f8f0L48-L49

I am trying to test a fix locally before pushing it.

@jong82
Copy link
Author

jong82 commented Mar 6, 2020

PR opened, built and tested locally. Ready to be merged.
#1025

@jong82
Copy link
Author

jong82 commented Mar 6, 2020

Built a new PR with a better fix by adding it to the list of unmodifiable types.
#1027

@MaxAller
Copy link

FWIW this changeset doesn't repro the issue:

<createTable tableName="serial_test">
    <column name="id" type="smallint">
        <constraints nullable="false" primaryKey="true"/>
    </column>
</createTable>

produces

CREATE TABLE public.serial_test (id SMALLINT NOT NULL, CONSTRAINT SERIAL_TEST_PKEY PRIMARY KEY (id));

in LiquiBase 3.8.8.

@molivasdat
Copy link
Contributor

Hi @jong82 Thanks for writing up this issue. This has been fixed a different way than the pull request 1027. Is it acceptable to close this issue as having been fixed?

@kevin-atx kevin-atx added hacktoberfest a month-long celebration of open-source software and Developers contribute by completing PRs and removed hacktoberfest a month-long celebration of open-source software and Developers contribute by completing PRs labels Sep 28, 2020
@StevenMassaro
Copy link
Contributor

I am unable to reproduce this issue with Liquibase 4.6.1.

I created a table in Postgres like this:

create table lb1015 (testcol smallint);

I ran liquibase generateChangeLog --changelogfile new.xml and liquibase generateChangeLog --changelogfile new.sql. They generated the following respective changesets:

    <changeSet author="Steve (generated)" id="1637253846084-1">
        <createTable tableName="lb1015">
            <column name="testcol" type="SMALLINT"/>
        </createTable>
    </changeSet>
-- changeset Steve:1637253843165-1
CREATE TABLE "public"."lb1015" ("testcol" SMALLINT);

Looks like it was resolved with this PR: #1046

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants