Almas Abdrazak
Almas Abdrazak

Reputation: 3632

Double quotes in update query

I have the following db in postgresql

create table car_wash(
  id integer PK,
  images text[]
)

To insert some data into images array I'm using spring boot, this is method from my repository interface

@Modifying
    @Query(value = "update car_wash set images=array_append(images,'' || :item || '') where id =:id",nativeQuery = true)
    void updateImage(@Param("item") String item,@Param("id")Integer id);

But when i put some string such as F:\eclipse\workspace\TestMail\test.txtin db this path is wrapped with double quotes "F:\eclipse\workspace\TestMail\test.txt" I have no idea why, but when I'm trying to remove some strings from images aray using this query UPDATE car_wash SET images= array_remove(images, '"F:\eclipse\workspace\TestMail\test.txt"');it's not deleted.What is the reason?

Upvotes: 0

Views: 499

Answers (1)

Almas Abdrazak
Almas Abdrazak

Reputation: 3632

Finally i found an answer . I don't know why but spring wrapp all the path strings into double quotes, to solve this you should to do th following carWashRepository.updateImage(newImage.getAbsolutePath().replace("\\", "/"), carWash.getId());

Upvotes: 1

Related Questions