Closed tankorsmash closed 7 months ago
Sorted this one out! It seems to be that because my arbitraryId
field was marked as strict with !
it gets evaluated immediately which seems to be part of the issue.
For any other Haskell newbies, I cloned Selda locally, I appended
executable sqlite-bug-repro
main-is: Main.hs
build-depends:
base >=4.10,
selda,
selda-sqlite
hs-source-dirs: app
default-language: Haskell2010
ghc-options: -O0 -g
to selda/selda-sqlite/selda-sqlite.cabal
and added the above file to selda/selda-sqlite/app/Main.hs
. Then I added tons of Debug.Trace.trace "some string"
calls everywhere to try and figure out why the GHCI debugger (via cabal v2-repl sqlite-bug-report
) was showing <unknown>
after I used :set -fbreak-on-exception
to run :trace testDb
.
I had also found a SO answer with a bunch of cool stuff I added to my ~/.ghci
.
Anyway, it seems like the reason it was <unknown>
was because the body of testDb
wasnt unpacked enough. I moved the DataRow initting into a let binding and the traceback suddenly showed it as the culprit:
let dataRow :: DataRow = DataRow { Main.arbitraryId = def :: ID DataRow
, Main.someInt = 123
}
in
withSQLite "./databaseFile.db" $
insert
dataRows
[ dataRow
]
I also have the following appended to selda's cabal.project
at the end of the file, I'm not sure if it helped:
optimization: 0
debug-info: True
package selda
ghc-options: -O0 -g
package selda-sqlite
ghc-options: -O0 -g
Thanks again for the library, hope this helps someone else too!
Thanks for the library! It's been nice to use and I was happy to follow along the official tutorial too!
I followed the
insert
docs as well as I could, but the following code throws aDefaultValueException
instead of inserting the rows into the SQLite database.The docs for
def
say:which is what I believe I'm doing; simply using it in an
insert
call.Interestingly, if I remove the
someInt
field onDataRow
the now-single-fieldDataRow
, it'll insert, but not if I give it a second or more fields. My actual project has a dozen fields, and it didn't seem to matter which fields were there with the id.I created a new project:
I'm using cabal-install version 3.6.2.0, GHC 8.10.7,
selda-0.5.2.0
andselda-sqlite-0.1.7.2
. If there's more info I can attach, please let me know! I'm not familiar enough with Haskell yet to make a good issue