armanbilge / porcupine Goto Github PK
View Code? Open in Web Editor NEWSkunk-inspired library for SQLite on JVM, Node.js, and Native
License: Apache License 2.0
Skunk-inspired library for SQLite on JVM, Node.js, and Native
License: Apache License 2.0
May be I'm holding it wrong, but here's the repro:
//> using lib "com.armanbilge::porcupine::0.0.1"
import porcupine.*, Codec.*
import cats.effect.*
object app extends IOApp.Simple:
def run =
Database.open[IO]("test.db").use { db =>
db.execute(
sql"drop table if exists help;".command
) *>
db.execute(
sql"create table if not exists help(id integer primary key not null, test text)".command
) *>
db.unique(
sql"insert into help(id, test) values ($integer, $text) returning id * 100"
.query(integer),
25L -> "howdy"
).flatMap(IO.println) *> // OK
db.unique(
sql"begin; update help set test = 'bye' where id = $integer; insert into help(id, test) values ($integer, $text); commit;".command,
(25L, 25L, "howdy")
).flatMap(IO.println) // NOT OK
}
Output:
2500
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at org.sqlite.core.CorePreparedStatement.batch(CorePreparedStatement.java:105)
at org.sqlite.jdbc3.JDBC3PreparedStatement.setLong(JDBC3PreparedStatement.java:299)
at porcupine.DatabasePlatform$$anon$1$$anon$2.cursor$$anonfun$1$$anonfun$1(dbplatform.scala:50)
at main$ @ app$.main(test.scala:6)
at main$ @ app$.main(test.scala:6)
at main$ @ app$.main(test.scala:6)
Differentiating this particular error condition from sqlite from all other errors (foreign keys, constraints, schema mismatch) is important, because the usual response to it is to retry.
So it would make sense to give these types of errors an ADT but still surface them to the user immediately as they occur
By redirecting through a Channel
we can ensure that queries are handled on a persistent blocking instead of forcing the query to always block the current thread.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.