2016-12-14 40 views
0

CrateDB是否允許爲對象列使用大寫或駝峯屬性名稱?我有這樣一個表:CrateDB崩潰中的camelCase列名稱與JDBC

create table objecttest(
age integer, 
name string, 
attrs object 
); 

使用INSERT語句:

insert into objecttest (age,name,attrs) values (30,'harry',{address = '123 street', city = 'city', IPaddress = '10.0.0.1'}); 

...在崩潰導致:

cr> select * from objecttest; 
+-----+---------------------------------------------------------------------+--------+ 
| age | attrs                | name | 
+-----+---------------------------------------------------------------------+--------+ 
| 30 | {"address": "123 street", "city": "city", "ipaddress": "10.0.0.1"} | harry | 
+-----+---------------------------------------------------------------------+--------+ 
SELECT 1 row in set (0.005 sec) 

...在CrateDB的JDBC驅動程序導致:

cr> select * from objecttest; 
+-----+---------------------------------------------------------------------+-------+ 
| age | attrs                | name | 
+-----+---------------------------------------------------------------------+-------+ 
| 30 | {"address": "123 street", "city": "city", "ipaddress": "10.0.0.1"} | harry | 
| 30 | {"IPaddress": "10.0.0.1", "address": "123 street", "city": "city"} | harry | 
+-----+---------------------------------------------------------------------+-------+ 
SELECT 2 rows in set (0.004 sec) 

IPaddress is now拼寫有所不同。這是一個在crate-jdbc中的錯誤嗎?

回答

1

如果不加引號,CrateDB會將所有列名視爲不區分大小寫(小寫),因此應引用任何列以保留大小寫。另一方面,CrateDB的JDBC驅動程序會自動引用列名,這意味着在那裏執行的插入語句將具有寫在代碼中的外殼。崩潰/管理員UI/...發出時,將使用保留外殼:

insert into objecttest (age,name,attrs) values (30,'harry',{address = '123 street', city = 'city', "IPaddress" = '10.0.0.1'}); 

你會得到相同的結果如果與箱子-JDBC插入。

更多關於結構here

乾杯!