-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow Codec#product to behave correctly with parameter count #94
base: main
Are you sure you want to change the base?
Conversation
The latest commit addresses point 1, with the |
JS support blocked by WiseLibs/better-sqlite3#1032 |
creates a binding dictionary explicitly on JS, zipping the arguments with their index and binding str(idx+1) to the argument
val argsList = bind(args) | ||
val argsDict: js.Dictionary[Any] = | ||
js.Dictionary(argsList.zipWithIndex.map { case (v, idx) => | ||
(s"${idx + 1}", v) | ||
}*) | ||
F.delay(statement.iterate(argsDict)).map { iterator => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this all in the delay
block, and I think we can build the JS object more efficiently without all the intermediate datastructures form zipWithIndex
and map
. Instead, we can just create a new js.Object
and set its keys with js.Dynamic
.
The way this is implemented is via a
parameters: Int
onEncoder
.Notes:
State[Int, String]
solution from Skunk was attempted, but there was no way to prevent the bad behavior of(someNonUnit, Codec.unit).tupled
from generating(?, ?, ?,)
rather than(?, ?, ?)
. A possible solution to this issue isState[Int, List[Either[String, Int]]]
, where the transitionsLeft→Left
,Left→Right
,Right→Left
are directly concatenated, but transitionsRight→Right
are joined with,
.${ a *: b *: nil }
, and I don't know why.Encoder#either
in this case.def parameters = 1
6 times.