Grails提供derived properties使用公式映射參數生成SQL表達式字段:Grails的派生屬性逃離公式
static mapping = {
myfield formula: "field1 + field2"
}
我試圖用公式參數與PostgreSQL數據庫進行一個連接的字段。因爲PostgreSQL的8.4尚不支持CONCAT_WS的語法有點怪:
static mapping = {
myfield formula: "array_to_string(array[field1, field2],' ')"
}
在DataSource配置與loggingSql =真顯示的生產SQL已經表前綴插入一些奇怪的地方:
錯誤地出現select table0_.field1 as field1_19_0_,
table0_.field2 as field2_19_0_,=
array_to_string(table0_.array[field1, table0_.field2], ' ') as formula0_0_
from test_table table0_ where table0_.id=?
表前綴之前陣列但不FIELD1派生式中之前。有沒有辦法避免前綴或更明確地糾正這種行爲?