Skip to content

Commit

Permalink
Add CreateCast and CreateCollation
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaireNeveu committed Sep 23, 2024
1 parent 5840027 commit 642c5c6
Showing 1 changed file with 49 additions and 2 deletions.
51 changes: 49 additions & 2 deletions packages/sij-dialect-postgresql/src/ast/schema-definition.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DataType, Ident, QualifiedIdent, StringLit } from 'sij-core/ast';
import { Tagged, UnTag, tag } from 'sij-core/util';

type PgSchemaDefinition = CreateAccessMethod | CreateAggregate;
type PgSchemaDefinition = CreateAccessMethod | CreateAggregate | CreateCast | CreateCollation;

/*
CREATE ACCESS METHOD name
Expand Down Expand Up @@ -119,4 +119,51 @@ interface AggregateOrderArgs
> {}
const AggregateOrderArgs = (args: UnTag<AggregateOrderArgs>): AggregateOrderArgs => tag('AggregateOrderArgs', args);

export { PgSchemaDefinition, CreateAccessMethod, CreateAggregate };
/*
CREATE CAST (source_type AS target_type)
WITH FUNCTION function_name [ (argument_type [, ...]) ]
[ AS ASSIGNMENT | AS IMPLICIT ]
CREATE CAST (source_type AS target_type)
WITHOUT FUNCTION
[ AS ASSIGNMENT | AS IMPLICIT ]
CREATE CAST (source_type AS target_type)
WITH INOUT
[ AS ASSIGNMENT | AS IMPLICIT ]
*/
interface CreateCast extends Tagged<'CreateCast', {
readonly sourceType: string;
readonly targetType: string;
readonly mode: 'WithoutFunction' | 'WithInout' | { name: string, args: Array<string> }
readonly implicit: null | 'AsAssignmnet' | 'AsImplicit'
}> {}
const CreateCast = (args: UnTag<CreateCast>): CreateCast => tag('CreateCast', args);

/*
CREATE COLLATION [ IF NOT EXISTS ] name (
[ LOCALE = locale, ]
[ LC_COLLATE = lc_collate, ]
[ LC_CTYPE = lc_ctype, ]
[ PROVIDER = provider, ]
[ DETERMINISTIC = boolean, ]
[ RULES = rules, ]
[ VERSION = version ]
)
CREATE COLLATION [ IF NOT EXISTS ] name FROM existing_collation
*/
interface CreateCollation extends Tagged<'CreateCollation', {
readonly name: Ident;
readonly options: Ident | {
readonly locale: string | null;
readonly lcCollate: string | null;
readonly lcCtype: string | null;
readonly provider: string | null;
readonly deterministic: boolean; // Default true
readonly rules: string | null;
readonly version: string | null;
}
}> {}
const CreateCollation = (args: UnTag<CreateCollation>): CreateCollation => tag('CreateCollation', args);

export { PgSchemaDefinition, CreateAccessMethod, CreateAggregate, CreateCast, CreateCollation };

0 comments on commit 642c5c6

Please sign in to comment.