CrateDB是否允许对象列具有大写或驼峰式的属性名?我有一张这样的桌子:
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)
现在,IP地址的拼写有所不同。这是crate-jdbc中的错误吗?
最佳答案
如果不带引号,则CrateDB会将所有列名称视为不区分大小写(小写),因此,应将任何列都加引号以保留大小写。另一方面,CrateDB的JDBC驱动程序将自动引用列名,这意味着在其中执行的插入语句将具有代码中编写的大小写形式。崩溃/管理员界面/ ...将在发布时使用保留大小写:
insert into objecttest (age,name,attrs) values (30,'harry',{address = '123 street', city = 'city', "IPaddress" = '10.0.0.1'});
您将获得与插入crate-jdbc相同的结果。
有关结构here的更多信息。
干杯!