Giter Site home page Giter Site logo

porcupine's People

Contributors

armanbilge avatar nimble-agar-steward[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

quafadas s5bug

porcupine's Issues

"Index out of bounds" when placeholder is repeated

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)


Consider special-casing "database is locked" exception

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.