20260916172703
This commit is contained in:
1 parent
dce29f250e
commit
de05498552
25 files changed
+1141
-1315
No files matched your search
@@ -1,5 +1,9 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildConditionSql, defaultQueryValue } from '@/components/fms-module-common/queryUtils'
|
||||
import {
|
||||
buildConditionSql,
|
||||
defaultQueryValue,
|
||||
sqlLiteral,
|
||||
} from '@/components/fms-module-common/queryUtils'
|
||||
import { formatDateValue, parseOptions } from '@/components/fms-module-common/fieldUtils'
|
||||
import { setMessages, translate } from '@/stores/i18n'
|
||||
|
||||
@@ -54,6 +58,20 @@ describe('fms-module-list query utilities', () => {
|
||||
).toBe("[status] IN (N'a', N'b')")
|
||||
})
|
||||
|
||||
it('日期时间字面量:自带时分秒按原时刻比较,仅日精度才补当天起 / 当天末', () => {
|
||||
const datetimeField = { b_field: 'created', b_type: 'datetime' }
|
||||
const dateField = { b_field: 'created', b_type: 'date' }
|
||||
|
||||
// datetime 值自带时分秒 → 原样保留,结束端也不再被夹到当天末
|
||||
expect(sqlLiteral('2026-01-01 09:30:00', datetimeField)).toBe("N'2026-01-01 09:30:00'")
|
||||
expect(sqlLiteral('2026-01-31 18:00:00', datetimeField, true)).toBe("N'2026-01-31 18:00:00'")
|
||||
// 只有日精度 → 按端点补默认时间
|
||||
expect(sqlLiteral('2026-01-01', datetimeField)).toBe("N'2026-01-01 00:00:00'")
|
||||
expect(sqlLiteral('2026-01-31', datetimeField, true)).toBe("N'2026-01-31 23:59:59'")
|
||||
// date 字段始终截到日,不补时分秒
|
||||
expect(sqlLiteral('2026-01-01 09:30:00', dateField)).toBe("N'2026-01-01'")
|
||||
})
|
||||
|
||||
it('parses options and normalizes defaults', () => {
|
||||
const parsed = parseOptions({ b_options: '{"options":[{"key":"1","name":"启用"},"2"]}' })
|
||||
expect(parsed.options).toEqual([
|
||||
|
||||
Reference in new issue
Block a user