Spring 数据 JPA/Flyway 转义双引号
Spring Data JPA / Flyway Escaping Double Quotes
我有一个使用 Spring Data JPA、Flyway 和 H2 的 spring 引导项目,它正在尝试处理包含以下 SQL 语句的迁移脚本:
ALTER ROLE current_user SET search_path TO "$user", public, my_schema;
当 Flyway 尝试 运行 此迁移时,出现以下错误:
---------------------------------
SQL State : 42001
Error Code : 42001
Message : Syntax error in SQL statement "ALTER ROLE[*] CURRENT_USER SET SEARCH_PATH TO ""$user"", PUBLIC, MY_SCHEMA"; expected "TABLE, USER, INDEX, SCHEMA, SEQUENCE, VIEW"; SQL statement:
ALTER ROLE current_user SET search_path TO "$user", public, my_schema [42001-200]
看起来好像在这个过程的某个地方,"$user"
周围的双引号被另外一组引号转义了。
我该如何解决这个问题?
ALTER ROLE
无效 h2 Command. (and that is also, how the error message sounds like.) I think you mean rather GRANT ROLE!(?)
如果需要转义"
,参考quoted names:
"anything"
| U&"anything" [ UESCAPE 'anything' ]
Case of characters in quoted names is preserved as is. Such names can
contain spaces. The maximum name length is 256 characters. Two double quotes can be used to create a single double quote inside an identifier. With default settings identifiers in H2 are case sensitive.
所以"$user"
应该没问题.
另请参阅:
我有一个使用 Spring Data JPA、Flyway 和 H2 的 spring 引导项目,它正在尝试处理包含以下 SQL 语句的迁移脚本:
ALTER ROLE current_user SET search_path TO "$user", public, my_schema;
当 Flyway 尝试 运行 此迁移时,出现以下错误:
---------------------------------
SQL State : 42001
Error Code : 42001
Message : Syntax error in SQL statement "ALTER ROLE[*] CURRENT_USER SET SEARCH_PATH TO ""$user"", PUBLIC, MY_SCHEMA"; expected "TABLE, USER, INDEX, SCHEMA, SEQUENCE, VIEW"; SQL statement:
ALTER ROLE current_user SET search_path TO "$user", public, my_schema [42001-200]
看起来好像在这个过程的某个地方,"$user"
周围的双引号被另外一组引号转义了。
我该如何解决这个问题?
ALTER ROLE
无效 h2 Command. (and that is also, how the error message sounds like.) I think you mean rather GRANT ROLE!(?)如果需要转义
"
,参考quoted names:
"anything" | U&"anything" [ UESCAPE 'anything' ]
Case of characters in quoted names is preserved as is. Such names can contain spaces. The maximum name length is 256 characters. Two double quotes can be used to create a single double quote inside an identifier. With default settings identifiers in H2 are case sensitive.
所以"$user"
应该没问题.
另请参阅: