Skip to content

Commit

Permalink
add collation to validate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mShan0 committed Nov 22, 2023
1 parent 2fa49c5 commit fbf3c74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/data-types/datetime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { type DataType } from '../data-type';
import DateTimeN from './datetimen';
import { ChronoUnit, LocalDate } from '@js-joda/core';
import { InternalConnectionOptions } from '../connection';
import { type InternalConnectionOptions } from '../connection';

import { Collation } from '../collation';

const EPOCH_DATE = LocalDate.ofYearDay(1900, 1);
const NULL_LENGTH = Buffer.from([0x00]);
Expand Down Expand Up @@ -77,7 +79,7 @@ const DateTime: DataType = {
},

// TODO: type 'any' needs to be revisited.
validate: function(value: any, options: InternalConnectionOptions): null | number {
validate: function(value: any, collation: Collation | undefined, options: InternalConnectionOptions): null | number {
if (value == null) {
return null;
}
Expand Down
6 changes: 3 additions & 3 deletions src/data-types/smalldatetime.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InternalConnectionOptions } from '../connection';
import { type InternalConnectionOptions } from '../connection';
import { type DataType } from '../data-type';
import DateTimeN from './datetimen';

import { Collation } from '../collation';
const EPOCH_DATE = new Date(1900, 0, 1);
const UTC_EPOCH_DATE = new Date(Date.UTC(1900, 0, 1));

Expand Down Expand Up @@ -55,7 +55,7 @@ const SmallDateTime: DataType = {
yield buffer;
},

validate: function(value, options: InternalConnectionOptions): null | Date {
validate: function(value, collation: Collation | undefined, options: InternalConnectionOptions): null | Date {
if (value == null) {
return null;
}
Expand Down

0 comments on commit fbf3c74

Please sign in to comment.