mmvergara / supadart

Typesafe queries in Supabase Flutter! Generate Flutter / Dart 🎯 classes from your Supabase schema.
https://supadart.vercel.app
MIT License
43 stars 5 forks source link

Nullable fields are generated for non null columns #92

Closed North101 closed 1 month ago

North101 commented 1 month ago

I have the following table

create table
  public.convention (
    id uuid not null default gen_random_uuid (),
    created_at timestamp with time zone not null default now(),
    updated_at timestamp with time zone not null default now(),
    creator_id uuid not null,
    name text not null,
    description text not null,
    start_date timestamp with time zone not null,
    end_date timestamp with time zone not null,
    constraint convention_pkey primary key (id),
    constraint convention_creator_id_fkey foreign key (creator_id) references creator (id),
    constraint name_length check ((char_length(name) >= 1)),
    constraint description_length check ((char_length(description) >= 1)),
    constraint date_check check ((end_date > start_date))
  ) tablespace pg_default;

which generates this

class Convention implements SupadartClass<Convention> {
  final String id;
  final DateTime? createdAt;
  final DateTime? updatedAt;
  final String? creatorId;
  final String name;
  final String description;
  final DateTime? startDate;
  final DateTime? endDate;
}

createdAt, updatedAt, creatorId, startDate and endDate are all non-nullable, but they have been generated with nullable types

mmvergara commented 1 month ago

I see, will do something about this just a bit busy in thesis, thanks for opening an issue

mmvergara commented 1 month ago

@North101 CLI Updated to 1.6.4 to fix the issue, please update your cli then try again, let me know if it worked as intended! <3

North101 commented 1 month ago

It works, thanks! I was about to open the same issue for views but after looking into it, it seems to unfortunately be a limitation of postgres :(