Closed Dsiefus closed 4 years ago
Hi,
are you worried about the columns themselves? I would assume regular SQL databases/query results do not have excessive amounts of columns.
When it comes to the data, i.e. in your example above "EUR"
, it will exist only once; it is merely referenced twice. While there obviously is some overhead because of this, it is not like all result data is actually duplicated.
In some cases the query could have many columns, and then the optional argument could be handy. I don't know if there are specific cases where it is desirable that the query result is stored like this, but I guess you have your reasons.
@tobij So if I understand the issue its just a flattening of references for the return object, and he wants one preserved in an easily mentally formatted form? Would this potentially open collisions of (n items more than one) with a common name child or would enacting an intentional collision of children potentially spring a safeguard and disable the feature of alias flattening?
I'm seeing an inline double depth ternary with assignment inside of a function's calling arguments. Thats impressively flexible and slightly terrifying. May I ask how num_rows() and num_fields() are being implimented? Are they like virtual overrides or an inheritance to be handled elsewhere? I have to learn more about your style, compiler and language! It seems to allow you to be VERY flexible.
Hmm... I'm not sure why f
is reassigned there, as it has already been set to num_fields()
a few lines earlier.
Anyway, Sql.pmod/sql_result.pike
is a remnant of the old Sql implementation.
For the current implementation, the base class is __builtin.pmod/Sql.pmod/Connection.pike
.
It would be interesting to have an option when performing an SQL query so that it doesn't need to return any duplicate information: for example, right now
SQL->query("select moneda from table where id=2");
Result: ({ ([ "moneda": "EUR", "users.moneda": "EUR" ]) })
Each row is stored twice in memory, one with the table name at the beginning and one without it. That can be a big waste of memory in some cases, so an optional parameter to indicate that only 1 of the (currently) 2 values needs to be returned/stored could be useful.