TheAngryByrd / Marten.FSharp

A set of FSharp wrappers around Marten
MIT License
74 stars 10 forks source link

Incorrect index created for Datetime option #9

Open sandeepc24 opened 7 years ago

sandeepc24 commented 7 years ago

For following type

type User = {
    Id : Guid
    Username : string
    Password : string    
    DOB : DateTime option
}

I define store as shown below

let store = DocumentStore.For(fun x -> 
    x.AutoCreateSchemaObjects <- AutoCreate.CreateOrUpdate
    x.Connection(ConnecitonString)
    x.Schema.For<User>().Index(fun x -> x.Username :> obj) |> ignore
    x.Schema.For<User>().Index(fun x -> x.DOB :> obj)|> ignore
    )

The index for DOB is created as

CREATE INDEX mt_doc_database_user_idx_dob
  ON public.mt_doc_database_user
  USING btree
  (((data ->> 'DOB'::text)::jsonb));

this should be as shown below

CREATE INDEX mt_doc_database_user_idx_dob
  ON public.mt_doc_database_user
  USING btree
  (mt_immutable_timestamp(data ->> 'DOB'::text));
ibnuda commented 7 years ago

Should be Marten's problem.

TheAngryByrd commented 7 years ago

Yeah this should be an opened on Marten's issue tracker: https://github.com/JasperFx/marten/issues

I'm not sure how pluggable the type generation is, but I'd be up for supporting F# types here if it's pluggable and doesn't want to support them in Marten main.

sandeepc24 commented 7 years ago

I think there was some talk about making serialization pluggable on gitter. IMO it would be better if we deal with it, that way F# won't have to rely on Marten for serialization implementation and fixes.

TheAngryByrd commented 6 years ago

I think I'll try to take a look at https://github.com/JasperFx/marten/issues/778 over the weekend and see if it's possible to add some F# types.

sandeepc24 commented 6 years ago

Thanks.