您应该使用准备好的语句来进行准确的类型映射

You should use prepared statements for accurate type mapping

为什么我会收到此错误消息?

TypeError: Target data type could not be guessed, you should use prepared statements for accurate type mapping. Value: {
  full_name: 'Hshsbsjah',
  profile_image: 'NULL',
  phone: 'NULL',
}

查询:

              const query = `INSERT INTO users (user_id, email, password, user_details, user_since) VALUES (?, ?, ?, ?, ?);`;
              const result = await client.execute(query, [ userid, body.email, body.password, 
               { 
                  full_name: body.fullname, 
                  profile_image: 'NULL',
                  phone: 'NULL',
                }, 
                luxon.DateTime.now() ], { prepared: true });
user_details UDT:

CREATE TYPE user_information (
  full_name text,
  profile_image text,
  phone text
)

这个问题是在 https://community.datastax.com/questions/11797/ 上提出的。

我已经联系了 DataStax 的驱动程序开发人员,我在这里重新发布了 Bret McGuire 的回答。

这里的代码有错别字:

luxon.DateTime.now() ], { prepared: true });

正确的 属性 键是 prepare 而不是 prepared。干杯!