SMF Development > Applied or Declined Requests
Automatically convert Rand() to Random()
Nibogo:
I think it'd be better if we do the conversion, I really don't think a lot of people is aware of that, not even developers
live627:
It's undocumented.
MrPhil:
So, if you write your SQL query as
--- Code: ---SELECT {RAND}() ....
--- End code ---
SMF would replace {RAND} by RAND or RANDOM, depending on which library is being used. That sounds easy enough to do. If an ignorant author only tests with RAND() in MySQL, it should even be possible to automatically flag that (to be fixed) during the submission process.
Is there a list of various database eccentricities beyond RAND/RANDOM? To future-proof code, you might want to go beyond the three databases that SMF handles, and be prepared to handle Oracle, DB2, Access, etc. should they ever become supported. Hopefully there aren't too many such cases, so SMF would not have to specially handle dozens of keywords or even put all function names in {}.
While improving cross-DB capabilities, how about discovering naked reserved keywords during submission testing, and suggesting that they be backticked? This might have to wait until a query is fully assembled (during test) and can be parsed in PHP before actually submitting to the database. Are there other things (triggers, stored procedures, etc.) that could be emulated if properly marked up in the query?
emanuele:
* emanuele adds this to the list of things to document.
But since it's already there is neither a bug, nor a feature request.
Navigation
[0] Message Index
[*] Previous page
Go to full version