Araq / ormin

Ormin -- An ORM for Nim.
MIT License
152 stars 18 forks source link

Allow custom functions #24

Closed huaxk closed 4 years ago

huaxk commented 4 years ago

Just change const functions to a compile-time sequence variable , you can implement custom function. so can write code:

static:
  functions.add([
    Function(name: "st_asgeojson", arity: 1, typ: dbVarchar),
    Function(name: "json", arity: 1, typ: dbJson),
  ])

let cities = query:
  select cities(id, name, st_asgeomjson(lnglat))

echo cities

It is possible to take advantage of databse built-in function.

Araq commented 4 years ago

Ok, can you add a test case for this please?

huaxk commented 4 years ago

It involves database operations, and need to set up a CI system based on github actions. I can try!

Araq commented 4 years ago

Please remove the tests/tpostgres binary file.

huaxk commented 4 years ago

I set up automated tests base on github actions, and tested crud, may be some problems with the delete operation, it raise unhandled exception. I test some sql function: upper and lower, which functions with only one parameter works ok! but others has problems.

Araq commented 4 years ago

Does that mean you want me to review it? Or is this "work in progress"?

huaxk commented 4 years ago

Yes, The automated tests has been set up. After you reviewed, then I can test more cases and fix the bug I found.

huaxk commented 4 years ago

The current test is mainly for postgresql, and the next step can also be for sqlite.

Araq commented 4 years ago

Looks good enough to me.