Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于内置sql的插入时 时间类型函数的引用问题 #102

Closed
z87506386 opened this issue Dec 2, 2022 · 5 comments
Closed

关于内置sql的插入时 时间类型函数的引用问题 #102

z87506386 opened this issue Dec 2, 2022 · 5 comments

Comments

@z87506386
Copy link

在使用ngbatis时,根据提供的demo,使用自带的insert插入语句, 在传入date类型数据时, 该语句使用datetime() 会导致插入失败.
之后使用date('2022-11-11')导入成功,而在点中存在一条数据时,datetime()则不会失败

@CorvusYe
Copy link
Collaborator

CorvusYe commented Dec 2, 2022

@z87506386
方便问一下数据库里,属性具体类型是什么吗?

@wey-gu
像这种跟有无数据相关的问题会不会跟内核有关系,比如说非严格属性类型?

@z87506386
Copy link
Author

具体的我前几天遇到的 我明天再尝试一下 然后给你发一个比较详细的问题

@zwzdream
Copy link

zwzdream commented Jun 6, 2023

使用date类型时,查询语句得到的结果不对
这是我的执行日志:
2023-06-06 19:04:12.324 DEBUG 26516 --- [nio-8200-exec-1] o.n.contrib.ngbatis.proxy.MapperProxy :
- proxyMethod: cup.biz.kg.ngbatis.dao.ConductManageDao$Proxy#selectComEdgeDetail
- session space: cnem_kg
- nGql:
fetch prop on test-time 'shijianceshi001'->'n2shijianceshi001'@0 yield properties(edge) as e

- params: {p0=`test-time` 'shijianceshi001'->'n2shijianceshi001'@0}
- result:ColumnName: [e], Rows: [{date=1991-01-01, datetime=utc datetime: 1991-01-01T09:09:10.000000, timezoneOffset: 0, name="bian测试001", time=utc time: 09:09:10.000000, timezoneOffset: 0, timestamp=662720950}]
- 使用Map<String, Object>接收

但是类型date转换成map接收后 得到的结果为:
Thu Jan 01 00:00:00 GMT+08:00 3891,
这是为啥?时区丢失?

@zwzdream
Copy link

zwzdream commented Jun 6, 2023

找到了,这个地方加了1900,这是为啥
private static Object transformDate(DateWrapper date) {
return new GregorianCalendar(date.getYear() + 1900, date.getMonth() - 1, date.getDay())
.getTime();
}

@CorvusYe
Copy link
Collaborator

CorvusYe commented Jun 6, 2023

找到了,这个地方加了1900,这是为啥
private static Object transformDate(DateWrapper date) {
return new GregorianCalendar(date.getYear() + 1900, date.getMonth() - 1, date.getDay())
.getTime();
}

我印象中date类型是有个差值的,回头我确认下,可以先用datetime类型来存?

@wey-gu wey-gu closed this as completed in c8c9c80 Jun 8, 2023
wey-gu added a commit that referenced this issue Jun 8, 2023
fix: #102 and clear time type mapping (v1.1.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants