moskytw / mosql

Build SQL with native Python data structure smoothly.
http://mosql.mosky.tw
MIT License
140 stars 17 forks source link

Supporting standard SQL functions #5

Closed uranusjr closed 11 years ago

uranusjr commented 11 years ago

Currently SQL functions need to be wrapped with mosql.util.raw. But the down side of raw is that everything in it needs to be escaped manually. Maybe some limited support should be provided, at least to standard SQL functions like AVG, COUNT, etc.

What I currently have in mind is to replace (taken from the documentation)

select('person', select=raw('count(*)'), group_by=('age', ))

with some simple syntax like

select('person', select=count('*'), group_by=('age',))

which should be pretty easy to provide.

moskytw commented 11 years ago

Yes, it will be.

Do you have a list of the standard functions?

uranusjr commented 11 years ago

I don't have the SQL standard to refer to, but SQL in a Nutshell contains a nice chapter about standard SQL functions.

moskytw commented 11 years ago

Oh, I see the ANSI SQL functions in Chapter 4. It is helpful.

I will find time to implement them. Thanks for it.

moskytw commented 11 years ago

Thanks the #14 pull request from @uranusjr. This standard functions are includes in dev branch now.