norm
norm copied to clipboard
Feature/#133 add public from row
THIS IS A FIRST DRAFT - THIS PR IS NOT MERGE READY - Find a list of things I want to finish before merging at the end of the post
This proc adds the feature requested by #133 : A way to interact with the database with arbitrary SQL, yet still benefit from norms incredibly useful parsing of Row to objects, just this time it allows for arbitrary object types instead of using models.
This has the following benefits:
- It becomes possible to interact with views which do not have an
id
column, as the user can define their own types for interacting with the view - It becomes possible to use norm for executing arbitrary complex SQL such as recursive queries, which was not possible before
The specific procs that allows this are:
- A modification of
fromRowPos
andfromRow
which now can deal with any ref object as opposed to onlyModel
types -
rawSelect
procs that make use of that and allow the user to pass non-Model ref object and a full SQL query to execute
A small side-benefit:
I observed around a 10% speed-up for my limited test-cases when executing the "new" version of fromRowPos
. The reason for this speed-up is that some computation has been moved to compile-time instead of runtime.
Things that would still need to be done:
- General review + Approval that this feature is wanted
- Figure out in which module procs such as
isContainer
,toOptional
andisEmptyColumn
should be stored, asrowutils
does not feel like the appropriate place for these - Figure out actually decent names for
isContainer
andtoOptional
. These names are (in my mind) only placeholders since I couldn't think of a better name for now. They are more "open" alternatives toisModel
andmodel
. With the new context of using ref object instead of Model howeverisRefObject
andrefObject
as names seemed confusing to me. - Write tests for the
rawSelect
procs (and maybe the modifiedfromRowPos
proc) ( @moigagoo I would proceed with this point and the ones below once we ironed out the other ones) - Add changelog changes
- Add nimibook docs