You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uniqueness keys can be converted into a [PersistValue] (but not parsed - there's no [PersistValue] -> Either Text (Unique record)?)
Uniqueness keys have a NonEmpty (FieldNameHS, FieldNameDB) associated - like a FieldDef or EntityDef
Primary keys and Unique keys are not interchangeable.
This is too much.
Here's a sketch of how I'd like to refactor this. First, I want to have classes for things that can be rendered into a database with multiple columns, as well as a class for parsing them out.
classToPersistValuesawheretoPersistValues::a-> [PersistValue]
classFromPersistValuesawhere-- note that we may want this to be something like Either Text ([PersistValue], a)-- if the idea is that we parse multiple columns, then it makes sense to have left oversfromPersistValues:: [PersistValue] ->EitherTexta
We can pretty easily have an instance of PersistField a => ToPersistValues (Only a). And we can make tuples for parsing out lots of stuff.
In #1133 I talk about using prairie, which pulls out EntityField, persistFieldLens, and other things from PersistEntity. That may not be feasible until we get the separation of types for inserting/reading from the database. I'm not sure if that's necessary.
Then that leaves our Key and Unique stuff. #1239 I think I'll put most of my thoughts in there about how to resolve it.
So, I think, for a path forward:
Implement the To/FromPersistValues classes and make them superclasses of PersistEntity.
Figure out the uniqueness keys design
a. Do we want to make that a superclass? It doesn't make sense for all things... it is perfectly possible in SQL to have a table without a primary key.
The text was updated successfully, but these errors were encountered:
Related to #1037 and #1239
Right now,
PersistEntity
has a ton of responsibilities. Here's the class definition (minus comments)So, a
PersistEntity record
implies:PersistEntityBackend record
that the type must be used with (probably can be deleted with Deprecate mpsGeneric #1250 )Key
for the record.[PersistValue]
, and parsed from a[PersistValue]
EntityField
that directly corresponds to that primary key (this is false for composite keys)entityDef Proxy :: EntityDef
for a given type.EntityField
instance for the type.[SomePersistField]
and parse one out of a[PersistValue]
.Unique
#1239[PersistValue]
(but not parsed - there's no[PersistValue] -> Either Text (Unique record)
?)NonEmpty (FieldNameHS, FieldNameDB)
associated - like aFieldDef
orEntityDef
This is too much.
Here's a sketch of how I'd like to refactor this. First, I want to have classes for things that can be rendered into a database with multiple columns, as well as a class for parsing them out.
We can pretty easily have an instance of
PersistField a => ToPersistValues (Only a)
. And we can make tuples for parsing out lots of stuff.In #1133 I talk about using
prairie
, which pulls outEntityField
,persistFieldLens
, and other things fromPersistEntity
. That may not be feasible until we get the separation of types for inserting/reading from the database. I'm not sure if that's necessary.Then that leaves our
Key
andUnique
stuff. #1239 I think I'll put most of my thoughts in there about how to resolve it.So, I think, for a path forward:
To/FromPersistValues
classes and make them superclasses ofPersistEntity
.a. Do we want to make that a superclass? It doesn't make sense for all things... it is perfectly possible in SQL to have a table without a primary key.
The text was updated successfully, but these errors were encountered: