In the case of (auto generated) placeholders I will pass a reference to the original value into DBI->bind_param() , so this will be fine.
It's the case of literals causing me headaches.
The raw concept in short:
- the DB-table is handled as a Perl package with it's proper namespace,
- the columns are constants in this package returning objects blessed into a class SQL::Column
- operators are overloaded for SQL::Column
- operations return objects of class SQL::Operation with nested attributes like {operator => "<", left => bless (['col'], '::Column'), right=> bless (["42"], '::Literal')
- higher syntax expressions like WHERE are just functions imported into that table package, dealing with the nested objects and returning another container object
- In the end I get an abstract syntax tree of nested objects which I can walk and translate to the target SQL dialect
So something like this
query {
package t_table;
WHERE
col < "42"
}
needs to distinguish if the literal was string "42" or 42
Of course I could think about overloading lt too, to have a more Perlish way to get the type (and crosscheck against the table's definition), but the more information I have to catch errors, the better.
I hope my approach is clearer now! :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.