Comments (10)
Would you please reformat your code as below:
```swift // yeah, Swift do { // correctly indented } ```
It will help a lot reading your question :-)
// yeah, Swift
do {
// correctly indented
}
from grdb.swift.
yes, having a great difficult with code formatting ... seems to want to strip out tabs and cr/lf
from grdb.swift.
ok, that should do ..
from grdb.swift.
Thanks ;-)
OK now it's crystal clear. The inDatabase method executes its closure argument in a protected dispatch queue. And a database complains if it is used outside of this queue:
dbQueue.inDatabase { db in
// In the queue of `db`
try! dbQueueMerge.inDatabase {dbMerge in
// In the queue of `dbMerge`
// And there `db` complains it is not in its queue:
try db.execute(...)
}
}
OK. That's a pattern that is not supported today. I have to think about it.
Meanwhile, you have two possible workarounds:
1- First fetch all data in the source database queue, and then write in the destination database queue. It's much less memory efficient than your tight and sharp loop, I agree. But if you don't have too much data to copy, this solution can be an acceptable workaround.
2- If you actually copy the whole content of a database in another, use the backup method.
from grdb.swift.
Hmm, I was afraid you would tell me something like that. I would have thought that merging a second database is a (fairly) common need. In the merge process PK values change so I'll have to go with option one.
Hope you can figure something out ... and thanks for the speedy replies!
from grdb.swift.
I would have thought that merging a second database is a (fairly) common need.
There are my needs, the ones of my coworkers, and the ones of users like you who are kind enough to ask for a feature. Now the merge is on the list of feature requests :-)
Hope you can figure something out
So do I. Until this time, use a workaround, and stay tuned on GRDB :-)
from grdb.swift.
@mtissington OK I eventually managed to find a solution:
dbQueue1.inDatabase { db1 in
dbQueue2.inDatabase { db2 in
// Both db1 and db2 can be used here.
}
}
from grdb.swift.
cool, will give it a try ....
from grdb.swift.
The fix has shipped in v0.66.0.
from grdb.swift.
confirmed that this now works - thanks
try dbQueue.inTransaction { db in
try dbQueueMerge.inDatabase {dbMerge in
from grdb.swift.
Related Issues (20)
- podspec is not including the Privacy manifest HOT 4
- SQLite error 283 (notification message): recovered 864 frames from WAL file HOT 1
- 6.25.0 does not support provisioning profiles HOT 3
- Question about usage of generated columns HOT 4
- Assertion failed: unexpected NULL value HOT 5
- Confusion over .including(all:) query HOT 6
- How can I do floating-point division on an association count? HOT 8
- Latest version 6.26.0 is not deployed to the Cocoapod HOT 4
- Please add the Privacy Manifest file to the v5.x release. HOT 1
- package 'package.swift' is using Swift tools version 3.1.0 which is no longer supported; consider using '/ swift-tools-version: 5.9' to specify the current tools... HOT 1
- Request: Add citation to the repo HOT 3
- Cocoapods hasn't published since 6.24.1 HOT 2
- Cocoapods 6.26.0 release is not available in Cocapods Specs repo HOT 1
- Privacy Manifest: Entry missing for accessing file timestamps via creationDate API HOT 4
- When transaction updating multiple records in the database, if one of the records does not exist, it leads to update failure. HOT 4
- Avoid conflict with other SPM packages by renaming the CSQLite SPM target
- ValueObservation.tracking called on the updating thread HOT 5
- GRDB does not seem to copy over all rows when inserting within a migration HOT 4
- Unable to decode database NULL value as Swift nil value of type Int? when using ScopeAdapter built from splittingRowAdapters HOT 13
- PlayerRequest.swift is identical in GRDBAsyncDemo and GRDBCombineDemo HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grdb.swift.