-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blob column type to singlestore #3739
base: beta
Are you sure you want to change the base?
Add blob column type to singlestore #3739
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we discussed blob types in SingleStore are not the same as blob types in SQLite
* It's recommended to use `text('...', { mode: 'json' })` instead of `blob` in JSON mode, because it supports JSON functions: | ||
* >All JSON functions currently throw an error if any of their arguments are BLOBs because BLOBs are reserved for a future enhancement in which BLOBs will store the binary encoding for JSON. | ||
* | ||
* https://www.sqlite.org/json1.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy-pasted sqlite comments, should be removed
if (config?.mode === 'json') { | ||
return new SingleStoreBlobJsonBuilder(name); | ||
} | ||
if (config?.mode === 'bigint') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need BigInt mode for blobs? We should support string and maybe buffer modes, but we can start by just mapping string data
: SingleStoreBlobJsonBuilderInitial<TName>; | ||
export function blob(a?: string | BlobConfig, b?: BlobConfig) { | ||
const { name, config } = getColumnNameAndConfig<BlobConfig | undefined>(a, b); | ||
if (config?.mode === 'json') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need JSON mode for blobs? We should support string and maybe buffer modes, but we can start by just mapping string data
@@ -163,7 +169,7 @@ const usersMySchemaTable = mySchema.table('userstest', { | |||
id: serial('id').primaryKey(), | |||
name: text('name').notNull(), | |||
verified: boolean('verified').notNull().default(false), | |||
jsonb: json('jsonb').$type<string[]>(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to remove json type from tests here. Blob should be tested separately. You can check MySQL varbinary as long as SingleStore blob should be pretty the same as MySQL varbinary: https://docs.singlestore.com/cloud/reference/sql-reference/data-types/blob-types/
Add the Blob column type to SingleStore
The blob implementation is very similar to the SQLite
drizzle-orm/columns/blob.ts