Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(better-sqlite3): Emit correct types instead of any#65

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
donbernar wants to merge1 commit intosqlc-dev:main
base:main
Choose a base branch
Loading
fromdonbernar:main

Conversation

@donbernar
Copy link

Sqlite's driver was not generating types properly, it was returning all columns asany attributes instead of inferring the type from the schema.

Here's an example:

-- schema.sqlCREATETABLEtenants (  idTEXTPRIMARY KEY,  nameTEXTNOT NULL,  slugTEXTNOT NULL UNIQUE,  deletedINTEGERNOT NULL DEFAULT0,  company_tinTEXTNOT NULL UNIQUE);

Source file:

-- name: Find :oneSELECT*FROM tenantsWHERE id= ?;

Generated code:

// ...exportinterfaceFindArgs{id:any;}exportinterfaceFindRow{id:any;name:any;slug:any;deleted:any;companyTin:any;}// ...

When debugging the driver I noticed the receivedColumn in thecolumnType method where:

constexample1={name:"id",notNull:true,isArray:false,comment:"",length:-1,isNamedParam:false,isFuncCall:false,scope:"",table:{catalog:"",schema:"",name:"tenants"},tableAlias:"",type:{catalog:"",schema:"",name:"TEXT"},isSqlcSlice:false,originalName:"id",unsigned:false,arrayDims:0,};constexample2={name:"deleted",notNull:true,isArray:false,comment:"",length:-1,isNamedParam:false,isFuncCall:false,scope:"",table:{catalog:"",schema:"",name:"tenants"},tableAlias:"",type:{catalog:"",schema:"",name:"INTEGER"},isSqlcSlice:false,originalName:"deleted",unsigned:false,arrayDims:0,};

I decided to convert thecolumn.type.name to lowercase and addTEXT andVARCHAR types to the switch case. After building the wasm module, I run it withexamples/sqlc.dev.yaml config file and the example file got updated.

@donbernar
Copy link
Author

donbernar commentedOct 8, 2025
edited
Loading

While working on this I noticed the Makefile is not compatible with the latest javy CLI version. I have not updated it in the PR, but changing line 8 with the following solved the issues:

image

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@donbernar

[8]ページ先頭

©2009-2025 Movatter.jp