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

Missing error code: UNKNOWN_SQLITE_ERROR_257 #1271

Closed
Meztlicoatl opened this issue Oct 8, 2024 · 5 comments
Closed

Missing error code: UNKNOWN_SQLITE_ERROR_257 #1271

Meztlicoatl opened this issue Oct 8, 2024 · 5 comments

Comments

@Meztlicoatl
Copy link
Contributor

I'm using a SQLite extension, particularly ICU support: I loaded it in the database creation and did normal things. Then, I tried to fill up that database with a separate script and connection, running a different ts-node instance. I forgot to update this script to also load this particular extension with the required connection, so I guess that was the cause.
Also, the error code description matches my guess: https://www.sqlite.org/rescode.html#error_missing_collseq

The error stack:

/path/to/project/backend/node_modules/better-sqlite3/lib/methods/wrappers.js:5
        return this[cppdb].prepare(sql, this, false);
                    ^
SqliteError: no such collation sequence: SPANISH
    at Database.prepare (/path/to/project/backend/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at Object.<anonymous> (/path/to/project/backend/source/database/development-setup.ts:9:12)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module.m._compile (/path/to/project/backend/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Object.require.extensions.<computed> [as .ts] (/path/to/project/backend/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24) {
  code: 'UNKNOWN_SQLITE_ERROR_257'
}

And the other main script where I loaded the extension:

const connection = new Database(serverRootPath('database/website.sqlite'))
connection.pragma('journal_mode = WAL')
const sqlite_version = (connection.prepare('SELECT sqlite_version() as version').get() as any).version
connection.loadExtension(assetPath(`database/libSQLiteICU-${sqlite_version}.so`))
connection.prepare('SELECT icu_load_collation(\'es_AR\', \'SPANISH\')').run()
// ...
connection.close()
@Prinzhorn
Copy link
Contributor

Do you have a question or just wanted to share this? As you said, you tried to access the database using a different process that didn't have the necessary extension to work with the database file.

@Meztlicoatl
Copy link
Contributor Author

I posted this issue as recommended here in the API docs:
image

@Prinzhorn
Copy link
Contributor

Prinzhorn commented Oct 9, 2024

Sorry, I did not realize that. It was not clear from your message, you should re-open the issue then as it has not been resolved.

I think the error needs to be added to

SetCode(isolate, SQLITE_OK_LOAD_PERMANENTLY, "SQLITE_OK_LOAD_PERMANENTLY");
if you're interested in creating a PR.

@Meztlicoatl Meztlicoatl reopened this Oct 9, 2024
@Meztlicoatl
Copy link
Contributor Author

Sorry for not being clear. First time doing this :D.
Fixed as requested and PR done #1273.

JoshuaWise pushed a commit that referenced this issue Oct 29, 2024
@Prinzhorn
Copy link
Contributor

I think you can close this now.

In the future you can link a PR in various way to an issue so that it closes automatically when the PR is merged. See https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue

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

No branches or pull requests

2 participants