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

Fix attaching to database if database does not exists #260

Merged
merged 3 commits into from
Aug 4, 2021

Conversation

Tomas2D
Copy link
Contributor

@Tomas2D Tomas2D commented Aug 4, 2021

Hey, I find out that attachOrCreate does not work properly – the createDatabase is never being called from attachOrCreate method.

The reason is that the error from the database is detected, but there is a pitfall in isError method, which mark input as error only and only if it is plain object and has status property on it, but in this case, the error message with status is attached to object, which is an instance of Database.

This pitfall was not detected in tests, because of not awaiting the detach method - so it never gets propagated.

Thanks.

@Tomas2D
Copy link
Contributor Author

Tomas2D commented Aug 4, 2021

Also, you will get a better error message if that happens.

This is the old message which you get by calling attach to a database that does not exist. It will also propagate only if the query is made.

Error: select 1 from RDB$DATABASE - invalid database handle (no active connection)

The new error is propagated immediately:

Received: [Error: I/O error during "open" operation for file "/tmp/test.fdb", Error while trying to open file]

@mariuz mariuz merged commit ec788e8 into hgourvest:master Aug 4, 2021
@Tomas2D Tomas2D deleted the fix/attach-or-create branch August 5, 2021 09:58
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.

None yet

2 participants