norm icon indicating copy to clipboard operation
norm copied to clipboard

Feature/#133 add public from row

Open PhilippMDoerner opened this issue 1 year ago • 0 comments

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 and fromRow which now can deal with any ref object as opposed to only Model 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 and isEmptyColumn should be stored, as rowutils does not feel like the appropriate place for these
  • Figure out actually decent names for isContainer and toOptional. These names are (in my mind) only placeholders since I couldn't think of a better name for now. They are more "open" alternatives to isModel and model. With the new context of using ref object instead of Model however isRefObject and refObject as names seemed confusing to me.
  • Write tests for the rawSelect procs (and maybe the modified fromRowPos 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

PhilippMDoerner avatar Aug 12 '22 20:08 PhilippMDoerner