|
Post by niuage on Jan 29, 2023 12:59:17 GMT
This one is more of a question about the code rather than something not working. I find `QueryFirstRecord` to be a bit misleading personally. It does what it says, but I think you would assume that it doesn't retrieve the whole table just to get the first one. If I have 10k records and use QueryFirstRecord, it would load 10k records in memory as far as I can see? To me it's a bit weird that the dev would need to include the LIMIT 1 in the query themselves, every time, when the method is called QueryFirstRecord. Just curious about what you think
|
|
|
Post by echo17 on Jan 30, 2023 9:56:00 GMT
The primary purpose for this method is to simplify getting one record. How that record is retrieved is entirely up to the user to provide full flexibility. I don’t want to change a query that might alter the expected results.
You could create a helper function in your own code that wraps this method, appending the limit one to each query you send. No need to modify the source code.
|
|
|
Post by niuage on Jan 31, 2023 21:43:40 GMT
Yes, that's what I'm doing I built a sort of ORM on top of SimpleSQL, I'm really happy with that solution over what I was doing before. I just wanted your stance on the subject, as I was personally not expecting a method called QueryFirstRecord to load all the records into memory. But all good, thx for the answer.
|
|
|
Post by echo17 on Feb 1, 2023 11:07:50 GMT
I see your point, and it does make sense. What I try to avoid is making any changes to what the user is passing to avoid unexpected results. For instance, if the user puts in a limit one in their query, and then mine puts another limit one on, then there will be a syntax error. It would be very hard to track down what is happening. The way I have it designed is so that what the user passes is exactly what they get.
The method itself just simplifies the syntax on how to get that record, without having to parse a list.
|
|
|
Post by niuage on Feb 13, 2023 8:32:02 GMT
Got it
|
|