ndb.nim icon indicating copy to clipboard operation
ndb.nim copied to clipboard

Best place to start contributions

Open JohnAD opened this issue 6 years ago • 5 comments

I'm thinking of helping out with this project. Where is a good place to start?

Off-the-cuff, I can see starting to add Postgresql support to the library, but I'm happy to start somewhere less ambitious.

JohnAD avatar May 31 '19 23:05 JohnAD

PostgreSQL support would be OK.

Some other things to do:

  • Add convenient unpacking support.

    # Something like this
    for a, b in db.rows[:(int64, string)](sql"SELECT 1, 'foo'"):
      ...
    
    # Instead of this
    for row in db.rows(sql"SELECT 1, 'foo'"):
       let a = row[0].i
       let b = row[1].s
       ...
    # or this
    for row in db.instantRows(sql"SELECT 1, 'foo'"):
       let a = row[0, int64]
       let b = row[1, string]
       ...
    
  • Prepared statements support.

  • Decouple common procs from SQLite-specific procs. This is partly done: procs marked with # Specific are specific to SQLite, whereas procs marked with # Common could be reused by other DMBS wrappers. Perhaps it may be easier to do after adding other wrappers, to make sure that these common procs actutally can be reused.

xzfc avatar Jun 01 '19 17:06 xzfc

@xzfc ,

I'm also helping out with the norm project, which is an ORM using Nim's native objects with databases. For that project, adding PostgreSQL is key. So, I'm thinking of this:

  1. write a short "How to use ndb" document to complement the technical documentation. I enjoy writing and having such a general document could be useful. And, more importantly, you can check my understanding of the library to make sure it matches up with your vision.

  2. Write a first pass at adding PostgreSQL support with a eye towards what parts are specific to sqlite and what parts are general between both databases. On this first pass, I will probably not support array and map columns, but I'll keep them in mind. I'll generate a "[WIP]" PR so that you can see progress and make comments as it goes along. I'll be mostly working on the weekends for this.

Sound good to you?

cc: @moigagoo

JohnAD avatar Jun 02 '19 18:06 JohnAD

Sounds good. Also I'll publish an wiki page about project design choices soon.

xzfc avatar Jun 02 '19 20:06 xzfc

Here: https://github.com/xzfc/ndb.nim/wiki/RFC

xzfc avatar Jun 05 '19 00:06 xzfc

There is not a way to add commentary to a wiki, not that I can see anyway. So, I'll add my thoughts here.

https://github.com/xzfc/ndb.nim/wiki/RFC#generalize-dbvalue

I've been thinking about this for a bit. I strongly recommend (b) db_* modules should reuse the common DbValue.

A few reasons for this:

  • Any app that uses multiple databases will find it very convenient. It's not just about avoiding conflicting namespaces, but also about having a good way to allow conversion. For example, if I have a row I'm importing from postgresql, and I want to save that row on sqlite, and one of the columns is a bool, it would be very nice that sqlite knew what do with a bool. (Which is to convert it to a INT.) And, yes, there are a lot of weird ones that would convert to TEXT/VARCHAR columns in other databases, but I don't see that as a burden, but a benefit that simply needs good documentation.

  • I'd keep it in a separate sub-library "x", so that projects that don't even use databases can find it of value. For example, if someone wanted to write a new database library. Essentially, both ndb/sqlite and ndb/postgres would import ndb/x. Speaking of...

  • To prep for this possibly becoming part of the standard library, I recommend getting a copy of db_common and making DbValue part of db_common. For now, sqlite and postgresql would import ndb/db_common. But later, they would simply import db_common if/when it becomes part of the standard library.

JohnAD avatar Jun 11 '19 14:06 JohnAD