Skip to content

Commit

Permalink
nits with datetime
Browse files Browse the repository at this point in the history
  • Loading branch information
drodrigues4 committed Jul 25, 2024
1 parent d1dbe61 commit b8686fa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drizzle-orm/src/singlestore-core/columns/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { entityKind } from '~/entity.ts';
import type { AnySingleStoreTable } from '~/singlestore-core/tables/common.ts';
import type { Equal } from '~/utils.ts';
import { SingleStoreColumn, SingleStoreColumnBuilder } from './common.ts';
import { sql } from '~/sql/sql.ts';

export type SingleStoreDateTimeBuilderInitial<TName extends string> = SingleStoreDateTimeBuilder<{
name: TName;
Expand All @@ -25,6 +26,18 @@ export class SingleStoreDateTimeBuilder<T extends ColumnBuilderBaseConfig<'date'
this.config.fsp = config?.fsp;
}

defaultNow(fsp?: DatetimeFsp | undefined) {
return fsp ?
this.default(sql`(now(${fsp}))`) :
this.default(sql`(now())`);
}

defaultCurrentTimestamp(fsp?: DatetimeFsp | undefined) {
return fsp ?
this.default(sql`(current_timestamp(${fsp}))`) :
this.default(sql`(current_timestamp())`);
}

/** @internal */
override build<TTableName extends string>(
table: AnySingleStoreTable<{ name: TTableName }>,
Expand Down

0 comments on commit b8686fa

Please sign in to comment.