简体   繁体   中英

PSQL/Spring Boot type syntax error for new column data that I am trying to add

Using Postgres and Spring Boot. Running into the following error when I try to add the following column and data to my table.

psql:resorts.sql:51: ERROR:  invalid input syntax for type smallint: "https://someurl.com/that-im/trying-to-add/"
LINE 24:     'https://someurl.com/that-im/trying-to-add/'

Where I add in the column in my Spring Boot Model the column above is a short but I clearly define this column as a String as seen here:

  @Column(name = "things")
  private short things;

  @Column(name = "item_url")
  private String itemUrl;

My sql file where I insert the data into the database looks like this:

INSERT INTO table (
    ...,
    things,
    item_url
) VALUES (
    ...,
    5,
    'https://someurl.com/that-im/trying-to-add/'
),(

When I remove the column for item_url and remove it and the url from the SQL file everything works, but as soon as I put them back in I get the error above. Any help would be appreciated.

What ended up being the case was that when the table in my database was initially created I had accidentally labeled the type for the item_url as a short. Despite changing it in the SB model file to a String it still wouldn't take on the table.

From there I attempted to DROP TABLE IF EXISTS which deleted my table but for some reason would not allow to re-create a table with the old name. So I went into the SB model file and SQL seeder file and changed the name of the table to something else. From there it was able to create aa new table with all of the correct data and types with no errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM