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

[12.x] Configure connection on SQLite connector #54588

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Feb 12, 2025

This PR moves the connection configurations logic from the SQLiteConnection class to the SQLiteConnector class, following the pattern of other database drivers. SQLite was the only DB driver that configured its connection in the Connection class instead of the Connector class. As part of this change, redundant Builder and Grammar methods have been removed. There are many pragma key/value pairs, so it doesn't make sense to have a method in both classes for each pragma key/value (added recently on #52052).

Why?

Since using multiple schemas in PostgreSQL and running test suites in SQLite is a common scenario, this PR allows us to support attaching databases in SQLite in the future without introducing a BC-breaking change.

Summary

  • Moved SQLite connection configuration logic from the SQLiteConnection class to the SQLiteConnector class to be consistent with other DB drivers.
  • Make a few remaining SQLite queries schema aware (continuing the work on [12.x] Enhance multi-database support #54274).
  • New Schema::connection('sqlite')->pragma($key, $value = null) method to get/set a pragma value.
    • This method also accepts schema-qualified keys, for example: Schema::pragma('schema_name.journal_mode', 'wal')
  • Removed redundant SQLiteGrammar::compileSetBusyTimeout(), compileSetJournalMode(), compileSetSynchronous(), compileEnableWriteableSchema(), and compileDisableWriteableSchema() methods.
  • Removed redundant SQLiteBuilder::setBusyTimeout(), setJournalMode(), and setSynchronous() methods:
    • Schema::setBusyTimeout(12345) -> Schema::pragma('busy_timeout', 12345)
    • Schema::setJournalMode('wal') -> Schema::pragma('journal_mode', 'wal')
    • Schema::setSynchronous('normal') -> Schema::pragma('synchronous', 'normal')

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@hafezdivandari hafezdivandari marked this pull request as ready for review February 12, 2025 21:34
@taylorotwell taylorotwell merged commit 4d73980 into laravel:master Feb 13, 2025
41 checks passed
@hafezdivandari hafezdivandari deleted the master-sqlite-connector branch February 13, 2025 15:41
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