Git Product home page Git Product logo

skunk-tables's People

Contributors

chuwy avatar sjrd avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

sjrd

skunk-tables's Issues

Migrate Query to ADT

Currently, when we transform query (e.g. by adding limit) we in fact just concatenate Fragments which is very unsafe. Instead I think we should create a SELECT AST (later for INSERT and UDPATE as well) and when transforming method is called - we can just patch the bits of this AST. The AST could live in compile-time only, thus it doesn't even have to be completely type-safe.

Select(All, From("persons"), Where(Gte("age", 18)))

Opaque types don't work if placed outside of the companion object of a table class

In the below code:

  opaque type Id = Long
  inline given IsColumn[Id] = ???

  case class Task(id: Id, title: Task.Title)
  object Task:
    opaque type Title = String
    inline given IsColumn[Title] = ???

    val table = Table.of[Task].withName("tasks").build

Columns in table end up being:

(TypedColumn["id", Long, "tasks", EmptyTuple], TypedColumn["title", Task.Title, "tasks", EmptyTuple])

And the only difference between Id and Title is that they're defined at different levels. I managed to narrow down this problem to quotidian.MacroMirror, i.e. at this moment at the very beginning of MacroTable existence I already have wrong types.

Opaque types not being handled in table classes

This is a regression since first RCs. If I use an opaque types as on of the members I get type mismatch errors:

[error] 68 |      Tuple1(columns.created_by.from(_.createdBy))
[error]    |                                     ^^^^^^^^^^^
[error]    |Found:    (_$1.createdBy : io.foldables.ratio.services.auth.model.Actor.Id)
[error]    |Required: java.util.UUID

Couldn't investigate it deeper, but there's some connection between where the type is defined (same file/object) and error message.

Anyway, getting rid of TypeRepr.of[Columns] in TableBuilder seems to be solving the problem.

Rework Table.get to provide non-unique columns

Currently it provides only columns with unique constraints. But:

  • that should be ok if we want to add non-unique column - we just make sure that there's always at least one unique column used
  • It also would allow columns.id > 10 which doesn't return single element - we must make sure there's always == operator used on a unique column

Add a notion of foreign keys

We can declare some members of a table class as "foreign keys", i.e. instead of an actual column in a table they're references to another relation-table. For example:

A persons table:

id first_name last_name
1  John       Smith  

A Person class:

case class Person(firstName: String, lastName: String, photos: List[Photo.Id])

Here, photos is a reference to persons_photos relation table:

person_id photo_id
1         1
1         2
1         3

So expressing this relation would look like:

Table
  .of[Person]
  .withName("persons")
  .withPrimary("id")
  .withForeign[Photo.Id]("photos", "id")
  .build

This way, whenever we do Person.table.get(personId) - it also queries all photos.

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.