@@ -28,7 +28,7 @@ describe('OracleQuery', () => {
2828 })
2929 ` , { adapter : 'oracle' } ) ;
3030
31- it ( 'uses TO_TIMESTAMP_TZ with milliseconds precision and preserves trailing Z ' , async ( ) => {
31+ it ( 'generates TO_TIMESTAMP_TZ with millisecond precision for date range filters ' , async ( ) => {
3232 await compiler . compile ( ) ;
3333
3434 const query = new OracleQuery (
@@ -48,7 +48,64 @@ describe('OracleQuery', () => {
4848
4949 const [ sql , params ] = query . buildSqlAndParams ( ) ;
5050
51+ // Verify TO_TIMESTAMP_TZ is used with proper ISO 8601 format including milliseconds
5152 expect ( sql ) . toContain ( 'TO_TIMESTAMP_TZ(:"?", \'YYYY-MM-DD"T"HH24:MI:SS.FF"Z"\')' ) ;
53+ expect ( sql ) . toMatch ( / c r e a t e d _ a t \s + > = \s + T O _ T I M E S T A M P _ T Z / ) ;
54+ expect ( sql ) . toMatch ( / c r e a t e d _ a t \s + < = \s + T O _ T I M E S T A M P _ T Z / ) ;
55+
56+ // Verify parameters include millisecond precision
5257 expect ( params ) . toEqual ( [ '2024-02-01T00:00:00.000Z' , '2024-02-02T23:59:59.999Z' ] ) ;
5358 } ) ;
59+
60+ it ( 'generates TRUNC function for day granularity grouping' , async ( ) => {
61+ await compiler . compile ( ) ;
62+
63+ const query = new OracleQuery (
64+ { joinGraph, cubeEvaluator, compiler } ,
65+ {
66+ measures : [ 'visitors.count' ] ,
67+ timeDimensions : [
68+ {
69+ dimension : 'visitors.createdAt' ,
70+ dateRange : [ '2024-01-01' , '2024-01-31' ] ,
71+ granularity : 'day'
72+ }
73+ ] ,
74+ timezone : 'UTC'
75+ }
76+ ) ;
77+
78+ const [ sql , params ] = query . buildSqlAndParams ( ) ;
79+
80+ // Verify TRUNC with DD format for day grouping
81+ expect ( sql ) . toContain ( 'TRUNC("visitors".created_at, \'DD\')' ) ;
82+ expect ( sql ) . toMatch ( / G R O U P B Y \s + T R U N C / ) ;
83+ expect ( params ) . toEqual ( [ '2024-01-01T00:00:00.000Z' , '2024-01-31T23:59:59.999Z' ] ) ;
84+ } ) ;
85+
86+ it ( 'generates TRUNC function for month granularity grouping' , async ( ) => {
87+ await compiler . compile ( ) ;
88+
89+ const query = new OracleQuery (
90+ { joinGraph, cubeEvaluator, compiler } ,
91+ {
92+ measures : [ 'visitors.count' ] ,
93+ timeDimensions : [
94+ {
95+ dimension : 'visitors.createdAt' ,
96+ dateRange : [ '2024-01-01' , '2024-12-31' ] ,
97+ granularity : 'month'
98+ }
99+ ] ,
100+ timezone : 'UTC'
101+ }
102+ ) ;
103+
104+ const [ sql , params ] = query . buildSqlAndParams ( ) ;
105+
106+ // Verify TRUNC with MM format for month grouping
107+ expect ( sql ) . toContain ( 'TRUNC("visitors".created_at, \'MM\')' ) ;
108+ expect ( sql ) . toMatch ( / G R O U P B Y \s + T R U N C / ) ;
109+ expect ( params ) . toEqual ( [ '2024-01-01T00:00:00.000Z' , '2024-12-31T23:59:59.999Z' ] ) ;
110+ } ) ;
54111} ) ;
0 commit comments