Skip to content
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

Open
wants to merge 3 commits into
base: beta
Choose a base branch
from

Conversation

Rodriguespn
Copy link
Contributor

Add the Blob column type to SingleStore

The blob implementation is very similar to the SQLite drizzle-orm/columns/blob.ts

@Rodriguespn Rodriguespn changed the title add blob column type to singlestore Add blob column type to singlestore Dec 10, 2024
@Rodriguespn Rodriguespn marked this pull request as ready for review December 16, 2024 17:22
Copy link
Member

@AndriiSherman AndriiSherman left a 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
Copy link
Member

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') {
Copy link
Member

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') {
Copy link
Member

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[]>(),
Copy link
Member

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants