Coder Social home page Coder Social logo

postgresql arrays? about drift HOT 7 CLOSED

Noxits avatar Noxits commented on June 18, 2024
postgresql arrays?

from drift.

Comments (7)

simolus3 avatar simolus3 commented on June 18, 2024 1

No problem - the fact that the custom type has to be specified twice here not intuitive at all, I consider this to be a flaw in drift. It's just not easy to fix...

from drift.

simolus3 avatar simolus3 commented on June 18, 2024

I think the postgres package only supports some array types, but we should definitely have support for those in drift_postgres.

Or is there a dark magic way with custom queries?

You can use custom SQL types as a workaround until we have official support for them. That's not even dark magic, an official API in package:drift_postgres will be built with the same thing :)

from drift.

simolus3 avatar simolus3 commented on June 18, 2024

I've added them to drift_postgres in c621ef9.

from drift.

Noxits avatar Noxits commented on June 18, 2024

Sweet, thanks :D

You can use custom SQL types as a workaround

Oopsies, totally forgot about this functionality, my bad

from drift.

Noxits avatar Noxits commented on June 18, 2024

Hmm, it seems I can get it working with default values

class User extends Table {
	Column<List<int>> get example => customType(PgTypes.bigIntArray).withDefault(const Constant([]))();
}

Throws :

Invalid argument (dart): Must be null, bool, String, int, DateTime, Uint8List or double: _ImmutableList len:0

from drift.

simolus3 avatar simolus3 commented on June 18, 2024

Ah right, I think you'd have that problem with all custom types - at the moment we're unfortunately unable to infer the type to apply in that context.

Does it work if you explicitly apply the type on the constant, e.g Constant([], PgTypes.bigIntArray)?

from drift.

Noxits avatar Noxits commented on June 18, 2024

It indeed does, thank you very much.

Sorry, I should really open my eyes somehow, the solution was right in front of me..

from drift.

Related Issues (20)

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.