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

Support mkdir -p behavior when DB file does not exist #180

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

jjcarstens
Copy link
Contributor

Currently, if you supply a DB path that includes directories which do not exist, sqlite3 will not attempt to create them and the open will crash.

This adds a quick attempt to mkdir on the db path to ensure all intermediary directories exist before attempting to create the DB file for cases that SQLITE_OPEN_CREATE flag is enabled and would expect the file to be created when non-existant

@warmwaffles
Copy link
Member

Why can't this be solved at the elixir level? I'd rather stay away from modifying c_src/sqlite3.c as that is the sqlite amalgamation file.

@jjcarstens
Copy link
Contributor Author

@warmwaffles You're totally right - In fact, @fhunleth and I were just talking about this. I just jumped the gun to C for who-knows-why 🤦

Sit tight - Better change coming up soon

@warmwaffles
Copy link
Member

@jjcarstens it's not a big deal, I admire the effort to dig into the sqlite3.c file. That thing is a pain to load in the text editor.

Currently, if you supply a DB path that includes directories which
do not exist, sqlite3 will not attempt to create them and the open
will crash.

This adds a quick attempt to `mkdir` on the db path to ensure all intermediary
directories exist before attempting to create the DB file for cases that
`SQLITE_OPEN_CREATE` flag is enabled and would expect the file to be
created when non-existant
@jjcarstens
Copy link
Contributor Author

Ok @warmwaffles - Much easier in Elixir 🤣

@warmwaffles
Copy link
Member

Much cleaner too!

@warmwaffles warmwaffles merged commit dec23bd into elixir-sqlite:main Dec 7, 2021
@warmwaffles
Copy link
Member

@jjcarstens
Copy link
Contributor Author

So fast! Thanks @warmwaffles ❤️

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