gpt4 book ai didi

java - 更新查询中的双引号

转载 作者:行者123 更新时间:2023-12-02 12:35:48 25 4
gpt4 key购买 nike

我在 postgresql 中有以下数据库

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

要将一些数据插入到图像数组中,我正在使用 Spring Boot,这是我的存储库界面中的方法

@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);

但是当我将一些字符串(例如 F:\eclipse\workspace\TestMail\test.txt)放入数据库时​​,此路径用双引号括起来 "F:\eclipse\workspace\TestMail\test.txt"我不知道为什么,但是当我尝试使用此查询从图像阵列中删除一些字符串 UPDATE car_wash SET images= array_remove(images, '"F:\eclipse\workspace\TestMail\test.txt"' );没有被删除,是什么原因?

最佳答案

终于我找到了答案。我不知道为什么,但是 spring 将所有路径字符串包装到双引号中,要解决这个问题,您应该执行以下操作 carWashRepository.updateImage(newImage.getAbsolutePath().replace("\\", "/") , carWash.getId());

关于java - 更新查询中的双引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45162177/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com