-
-
Notifications
You must be signed in to change notification settings - Fork 102
fix: lazy-load full values for truncated columns in detail pane #446
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
629fdfc
fix: lazy-load full values for truncated LONGTEXT/MEDIUMTEXT/CLOB col…
datlechin e7f43c2
fix: revert unrelated pbxproj changes
datlechin 4e14162
fix: address code review issues for lazy-load truncated columns
datlechin b217d63
fix: address CodeRabbit review comments
datlechin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30625,6 +30625,9 @@ | |
| } | ||
| } | ||
| } | ||
| }, | ||
| "truncated" : { | ||
|
|
||
| }, | ||
| "Truncated — read only" : { | ||
| "localizations" : { | ||
|
|
||
63 changes: 63 additions & 0 deletions
63
TablePro/Views/Main/Extensions/MainContentCoordinator+LazyLoadColumns.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // | ||
| // MainContentCoordinator+LazyLoadColumns.swift | ||
| // TablePro | ||
| // | ||
| // Lazy-loads full values for columns truncated by ColumnExclusionPolicy. | ||
| // | ||
|
|
||
| import Foundation | ||
| import os | ||
| import TableProPluginKit | ||
|
|
||
| private enum LazyLoadLog { | ||
| static let logger = Logger(subsystem: "com.TablePro", category: "LazyLoadColumns") | ||
| } | ||
|
|
||
| internal extension MainContentCoordinator { | ||
| func fetchFullValuesForExcludedColumns( | ||
| tableName: String, | ||
| primaryKeyColumn: String, | ||
| primaryKeyValue: String, | ||
| excludedColumnNames: [String] | ||
| ) async throws -> [String: String?] { | ||
| guard !excludedColumnNames.isEmpty else { return [:] } | ||
| guard let driver = DatabaseManager.shared.driver(for: connectionId) else { | ||
| throw DatabaseError.notConnected | ||
| } | ||
|
|
||
| let quotedCols = excludedColumnNames.map { queryBuilder.quoteIdentifier($0) } | ||
| let quotedTable = queryBuilder.quoteIdentifier(tableName) | ||
| let quotedPK = queryBuilder.quoteIdentifier(primaryKeyColumn) | ||
|
|
||
| // Resolve parameter style from plugin metadata (? for MySQL/SQLite, $1 for PostgreSQL) | ||
| let paramStyle = PluginMetadataRegistry.shared | ||
| .snapshot(forTypeId: connection.type.pluginTypeId)?.parameterStyle ?? .questionMark | ||
| let placeholder: String | ||
| switch paramStyle { | ||
| case .dollar: | ||
| placeholder = "$1" | ||
| case .questionMark: | ||
| placeholder = "?" | ||
| } | ||
|
|
||
| let query = "SELECT \(quotedCols.joined(separator: ", ")) FROM \(quotedTable) WHERE \(quotedPK) = \(placeholder)" | ||
|
|
||
| LazyLoadLog.logger.debug("Lazy-loading excluded columns: \(excludedColumnNames.joined(separator: ", "), privacy: .public)") | ||
|
|
||
| let result = try await driver.executeParameterized( | ||
| query: query, | ||
| parameters: [primaryKeyValue] | ||
| ) | ||
|
|
||
| guard let row = result.rows.first else { | ||
| LazyLoadLog.logger.warning("No row returned for lazy-load query") | ||
| return [:] | ||
| } | ||
|
|
||
| var dict: [String: String?] = [:] | ||
| for (index, colName) in excludedColumnNames.enumerated() where index < row.count { | ||
| dict[colName] = row[index] | ||
| } | ||
| return dict | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.