{"version":3,"file":"int.cjs","names":["SingleStoreColumnBuilderWithAutoIncrement","entityKind","SingleStoreColumnWithAutoIncrement"],"sources":["../../../src/singlestore-core/columns/int.ts"],"sourcesContent":["import type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { SingleStoreTable } from '~/singlestore-core/table.ts';\nimport { type Equal, getColumnNameAndConfig } from '~/utils.ts';\nimport { SingleStoreColumnBuilderWithAutoIncrement, SingleStoreColumnWithAutoIncrement } from './common.ts';\n\nexport class SingleStoreIntBuilder<TUnsigned extends boolean | undefined>\n\textends SingleStoreColumnBuilderWithAutoIncrement<{\n\t\tdataType: Equal<TUnsigned, true> extends true ? 'number uint32' : 'number int32';\n\t\tdata: number;\n\t\tdriverParam: number | string;\n\t}, SingleStoreIntConfig>\n{\n\tstatic override readonly [entityKind]: string = 'SingleStoreIntBuilder';\n\n\tconstructor(name: string, config?: SingleStoreIntConfig) {\n\t\tsuper(name, config?.unsigned ? 'number uint32' : 'number int32' as any, 'SingleStoreInt');\n\t\tthis.config.unsigned = config ? config.unsigned : false;\n\t}\n\n\t/** @internal */\n\toverride build(table: SingleStoreTable) {\n\t\treturn new SingleStoreInt(\n\t\t\ttable,\n\t\t\tthis.config as any,\n\t\t);\n\t}\n}\n\nexport class SingleStoreInt<T extends ColumnBaseConfig<'number int32' | 'number uint32'>>\n\textends SingleStoreColumnWithAutoIncrement<T, SingleStoreIntConfig>\n{\n\tstatic override readonly [entityKind]: string = 'SingleStoreInt';\n\n\tgetSQLType(): string {\n\t\treturn `int${this.config.unsigned ? ' unsigned' : ''}`;\n\t}\n\n\toverride mapFromDriverValue = (value: number | string): number => {\n\t\tif (typeof value === 'string') {\n\t\t\treturn Number(value);\n\t\t}\n\t\treturn value;\n\t};\n}\n\nexport interface SingleStoreIntConfig<TUnsigned extends boolean | undefined = boolean | undefined> {\n\tunsigned?: TUnsigned;\n}\n\nexport function int<TUnsigned extends boolean | undefined>(\n\tconfig?: SingleStoreIntConfig<TUnsigned>,\n): SingleStoreIntBuilder<TUnsigned>;\nexport function int<TUnsigned extends boolean | undefined>(\n\tname: string,\n\tconfig?: SingleStoreIntConfig<TUnsigned>,\n): SingleStoreIntBuilder<TUnsigned>;\nexport function int(a?: string | SingleStoreIntConfig, b?: SingleStoreIntConfig) {\n\tconst { name, config } = getColumnNameAndConfig<SingleStoreIntConfig>(a, b);\n\treturn new SingleStoreIntBuilder(name, config);\n}\n"],"mappings":";;;;;;;AAMA,IAAa,wBAAb,cACSA,kFAKT;CACC,QAA0BC,0BAAsB;CAEhD,YAAY,MAAc,QAA+B;AACxD,QAAM,MAAM,QAAQ,WAAW,kBAAkB,gBAAuB,iBAAiB;AACzF,OAAK,OAAO,WAAW,SAAS,OAAO,WAAW;;;CAInD,AAAS,MAAM,OAAyB;AACvC,SAAO,IAAI,eACV,OACA,KAAK,OACL;;;AAIH,IAAa,iBAAb,cACSC,2EACT;CACC,QAA0BD,0BAAsB;CAEhD,aAAqB;AACpB,SAAO,MAAM,KAAK,OAAO,WAAW,cAAc;;CAGnD,AAAS,sBAAsB,UAAmC;AACjE,MAAI,OAAO,UAAU,SACpB,QAAO,OAAO,MAAM;AAErB,SAAO;;;AAeT,SAAgB,IAAI,GAAmC,GAA0B;CAChF,MAAM,EAAE,MAAM,kDAAwD,GAAG,EAAE;AAC3E,QAAO,IAAI,sBAAsB,MAAM,OAAO"}