Skip to content

refactor!: remove legacy expo driver#11860

Merged
alumni merged 2 commits intotypeorm:masterfrom
G0maa:fix/remove-old-expo-driver
Dec 20, 2025
Merged

refactor!: remove legacy expo driver#11860
alumni merged 2 commits intotypeorm:masterfrom
G0maa:fix/remove-old-expo-driver

Conversation

@G0maa
Copy link
Copy Markdown
Collaborator

@G0maa G0maa commented Dec 20, 2025

Description of change

Fixes #11854

Pull-Request Checklist

  • Code is up-to-date with the next branch
  • This pull request links relevant issues as Fixes #00000
  • There are new or updated tests validating the change (tests/**.test.ts)
  • Documentation has been updated to reflect this change (docs/docs/**.md)

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Error Timing

The legacy driver check throws an error in the constructor before this.sqlite is assigned. If the error is caught and handled elsewhere, this.sqlite will be undefined, potentially causing issues in other methods that depend on it. Consider checking the driver type before calling the parent constructor or ensure proper cleanup.

if (this.isLegacyDriver) {
    throw new TypeORMError("Legacy Expo driver is not supported.")
}
Type Safety

The isLegacyDriver check uses a runtime property check ('openDatabaseAsync' in this.options.driver) which may not be type-safe. If this.options.driver is undefined or null, this will throw a runtime error. Consider adding a null/undefined check before the in operator.

private get isLegacyDriver(): boolean {
    return !("openDatabaseAsync" in this.options.driver)
}

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Dec 20, 2025

commit: ec13040

@qodo-free-for-open-source-projects
Copy link
Copy Markdown

qodo-free-for-open-source-projects bot commented Dec 20, 2025

PR Code Suggestions ✨

Latest suggestions up to ec13040

CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for driver

Add a null check for this.options.driver in the ExpoDriver constructor before it
is used to prevent a potential runtime error if it is not configured.

src/driver/expo/ExpoDriver.ts [11-19]

 constructor(connection: DataSource) {
     super(connection)
+
+    if (!this.options.driver) {
+        throw new TypeORMError("Expo driver is not configured.")
+    }
 
     if (this.isLegacyDriver) {
         throw new TypeORMError("Legacy Expo driver is not supported.")
     }
 
     this.sqlite = this.options.driver
 }
  • Apply / Chat
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that accessing this.options.driver within the isLegacyDriver getter can cause a TypeError if it's undefined. Adding a preceding check improves robustness and provides a clearer error message for misconfiguration.

Medium
  • More

Previous suggestions

Suggestions up to commit a885632
CategorySuggestion                                                                                                                                    Impact
Possible issue
Add null check for driver

Add a null check for this.options.driver in the ExpoDriver constructor before it
is accessed to prevent a potential runtime error and provide a clearer error
message for misconfiguration.

src/driver/expo/ExpoDriver.ts [11-19]

 constructor(connection: DataSource) {
     super(connection)
+
+    if (!this.options.driver) {
+        throw new TypeORMError("Expo driver is not configured.")
+    }
 
     if (this.isLegacyDriver) {
         throw new TypeORMError("Legacy Expo driver is not supported.")
     }
 
     this.sqlite = this.options.driver
 }
Suggestion importance[1-10]: 7

__

Why: The suggestion correctly identifies that this.isLegacyDriver will throw a TypeError if this.options.driver is not provided, and proposes adding a check to handle this case with a more informative error message.

Medium
Suggestions up to commit 8260666
CategorySuggestion                                                                                                                                    Impact
Possible issue
Ensure options are initialized before access

Refactor the ExpoDriver constructor to ensure this.options is initialized before
use and to improve code clarity by caching this.options.driver.

src/driver/expo/ExpoDriver.ts [11-19]

 constructor(connection: DataSource) {
     super(connection)
 
-    if (this.isLegacyDriver) {
+    const driver = this.options.driver
+    if (!("openDatabaseAsync" in driver)) {
         throw new TypeORMError("Legacy Expo driver is not supported.")
     }
 
-    this.sqlite = this.options.driver
+    this.sqlite = driver
 }
Suggestion importance[1-10]: 4

__

Why: The suggestion correctly identifies a potential race condition but this.options is initialized in the super() call, making the concern valid but not an actual bug. The proposed code refactoring is a minor improvement for readability and to avoid a repeated property access.

Low
Suggestions up to commit a1eea7e
CategorySuggestion                                                                                                                                    Impact
High-level
This PR introduces an unannounced breaking change

The PR removes support for the legacy Expo driver, constituting a breaking
change. It is recommended to update the PR description and official
documentation to announce this change and provide migration guidance for users.

Examples:

src/driver/expo/ExpoDriver.ts [14-16]
        if (this.isLegacyDriver) {
            throw new TypeORMError("Legacy Expo driver is not supported.")
        }
src/driver/expo/ExpoDriverFactory.ts [1-23]

Solution Walkthrough:

Before:

// src/driver/DriverFactory.ts
class DriverFactory {
    create(connection: DataSource): Driver {
        switch (connection.options.type) {
            // ...
            case "expo":
                return new ExpoDriverFactory(connection).create()
            // ...
        }
    }
}

// src/driver/expo/ExpoDriverFactory.ts (deleted file)
class ExpoDriverFactory {
    create(): ExpoDriver | ExpoLegacyDriver {
        if (this.isLegacyDriver) {
            return new ExpoLegacyDriver(this.connection)
        }
        return new ExpoDriver(this.connection)
    }
}

After:

// src/driver/DriverFactory.ts
class DriverFactory {
    create(connection: DataSource): Driver {
        switch (connection.options.type) {
            // ...
            case "expo":
                return new ExpoDriver(connection)
            // ...
        }
    }
}

// src/driver/expo/ExpoDriver.ts
export class ExpoDriver extends AbstractSqliteDriver {
    constructor(connection: DataSource) {
        super(connection)
        if (this.isLegacyDriver) {
            throw new TypeORMError("Legacy Expo driver is not supported.")
        }
        // ...
    }
}
Suggestion importance[1-10]: 10

__

Why: The suggestion correctly identifies a critical, unannounced breaking change by removing support for the legacy Expo driver, which will cause applications to fail upon upgrade.

High
Possible issue
Prevent TypeError on undefined driver

Add a check to ensure this.options.driver is defined before using the in
operator to prevent a potential TypeError.

src/driver/expo/ExpoDriver.ts [41-43]

 private get isLegacyDriver(): boolean {
-    return !("openDatabaseAsync" in this.options.driver)
+    return !this.options.driver || !("openDatabaseAsync" in this.options.driver)
 }
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly identifies a potential TypeError if this.options.driver is undefined and provides a valid fix, improving the robustness of the newly added code.

Low

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 20, 2025

Coverage Status

coverage: 80.911% (+0.1%) from 80.795%
when pulling ec13040 on G0maa:fix/remove-old-expo-driver
into 22ed3ec on typeorm:master.

@G0maa G0maa requested review from alumni, gioboa and mguida22 December 20, 2025 09:58
Copy link
Copy Markdown
Collaborator

@alumni alumni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @G0maa, thanks for this! Can you target the master branch for this PR?

Also, in that branch there's a migration guide in the docs that should be updated.

For a few versions Expo provided both SQLite APIs. The old API was removed in v52. The new API existed before that, but I didn't check when it was introduced. I think the officially supported Expo versions are v53-v55.

CC: @pmk1c @brentvatne

@alumni alumni changed the title fix: remove old expo driver refactor!: remove old expo driver Dec 20, 2025
@alumni alumni changed the title refactor!: remove old expo driver refactor!: remove legacy expo driver Dec 20, 2025
@G0maa G0maa changed the base branch from next to master December 20, 2025 11:55
@G0maa G0maa force-pushed the fix/remove-old-expo-driver branch from a1eea7e to 8260666 Compare December 20, 2025 11:59
@G0maa G0maa force-pushed the fix/remove-old-expo-driver branch from 8260666 to a885632 Compare December 20, 2025 12:06
@G0maa G0maa requested a review from alumni December 20, 2025 13:00
Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @G0maa 👏

@alumni alumni merged commit 9f67f57 into typeorm:master Dec 20, 2025
64 checks passed
mgohin pushed a commit to mgohin/typeorm that referenced this pull request Jan 15, 2026
kranners pushed a commit to kranners/typeorm that referenced this pull request Mar 1, 2026
@pkuczynski pkuczynski added this to the 1.0 milestone Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Remove old Expo driver

5 participants