Skip to content

Support mapping BIGINT to string in MySQL #15

Closed
@yshrsmz

Description

@yshrsmz

Currently sqlc-gen-typescript maps MySQL's BIGINT type to number type, but the max value of number type is far smaller than that of BIGINT.

node-mysql2 supports big numbers by converting it to string, so sqlc should also support mapping bigint to string.

https://github.com/mysqljs/mysql#connection-options

Here's a related quote from the doc

supportBigNumbers: When dealing with big numbers (BIGINT and DECIMAL columns) in the database, you should enable this option (Default: false).
bigNumberStrings: Enabling both supportBigNumbers and bigNumberStrings forces big numbers (BIGINT and DECIMAL columns) to be always returned as JavaScript String objects (Default: false). Enabling supportBigNumbers but leaving bigNumberStrings disabled will return big numbers as String objects only when they cannot be accurately represented with [JavaScript Number objects] (https://tc39.es/ecma262/#sec-ecmascript-language-types-number-type) (which happens when they exceed the [-2^53, +2^53] range), otherwise they will be returned as Number objects. This option is ignored if supportBigNumbers is disabled.

I think we can simply navigate users to enable those two options to use BIGING support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions