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

Remove shadow tables from database dump #1477

Merged
merged 4 commits into from
Jan 6, 2024
Merged

Conversation

groue
Copy link
Owner

@groue groue commented Jan 6, 2024

This pull request fixes #1464 by not recording shadow tables from dumpContent(format:to:).

Shadow tables are implementation details of virtual tables (FTS4, FTS5, ...) that do not provide useful information in database dumps.


Caveat: detection of shadow tables uses PRAGMA table_list and requires SQLite 3.37+ (iOS 15.4, macOS 12.4, tvOS 15.4, watchOS 8.5). When run with older SQLite versions, shadow tables are still recorded.

This might bother applications that use the GRDBSnapshotTesting companion library, because the test results change, depending on the SQLite version 😬

A possible solution is to skip those tests until SQLite 3.37+, as in the sample code below:

import GRDB
import GRDBSnapshotTesting
import InlineSnapshotTesting
import XCTest

class MyDatabaseTests: XCTestCase {
    func test_full_database_content() throws {
        // Database snapshot contains undesired shadow tables
        // unless we run SQLite 3.37+.
        guard sqlite3_libversion_number() >= 3037000 else {
            throw XCTSkip("Can't snapshot database before SQLite 3.37")
        }
        
        let dbQueue = try makeMyDatabase()
        assertInlineSnapshot(of: dbQueue, as: .dumpContent()) {
            ...
        }
    }
}

@groue groue changed the title Don't dump shadow tables Remove shadow tables from database dump Jan 6, 2024
@groue groue changed the base branch from master to development January 6, 2024 18:52
@groue groue merged commit 18d2d51 into development Jan 6, 2024
21 checks passed
@groue groue deleted the dev/dump-virtual-tables branch January 6, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant