-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL select with Alaises #6
Comments
The spaces in the "AS" clauses is confirmed
I can't reproduce this behavior, do you have another snippet that shows it? Currently the ternary is checking if the key is a string where "origin" and "file_type" would give me integer keys. $selectWithAliases = array(
"origin",
"file_type",
"year" => "publication_year"
); This is what I'm testing on PHP 7.1.6, is this an inconsistency in PHP versions? $soql = new SoqlQuery();
$soql->select(array(
'origin',
'file_type',
'year' => 'publication_year'
));
// $select=origin,file_type,year AS publication_year
$result = (string)$soql; |
Hi, With respect to point 2: We were not able to generate an array with mix of (key=>value and value) with the parser. We could only generate an array with (key=>value and key=> null) . It would be great if you can add this additional check to handle the same. Also, let us know if you have any alternative approach to this problem. |
What's the generated structure look like from Symfony? I'm cool with adding the additional check 👍 Probably just need to convert it into an if statement since the nested ternaries are getting hard to understand |
It generates the following array formats:
We tried the combination of array("key" => "value" , "value") but Symfony is not able to recognize this format. |
Ah, that makes sense. In your PR, could you do the following and I'll merge it in:
|
I have completed the above. Hope the test cases are fine. |
In original documentation , Select query with aliases is given the following explanation:
https://github.com/allejo/PhpSoda/wiki/Working-with-SoQL-Queries
I came across two issues while working with aliases:
eg: $selectWithAliases = array(
"origin" => "origin_type"
);
URL formed: https://.../.../...?$select=origin AS origin
Expected URL: https://.../.../...?$select=origin%20AS%20origin
eg: $selectWithAliases = array(
"origin",
"file_type",
"year" => "publication_year"
);
URL formed: https://.../.../...?$select=origin AS ,file_type AS ,year AS publication_year
Expected URL: https://.../.../...?$select=origin,filer_name,year AS publication_year
A patch is required in line 169 of src/SoqlQuery.php to fix these 2 issues:
$formattedValues[] = (is_string($key) && (!is_null($value))) ? rawurlencode(sprintf($format, trim($key), trim($value))) : (is_string($key) ? $key : $value);
(is_string($key) && (!is_null($value))) ? rawurlencode(sprintf($format, trim($key), trim($value))) : (is_string($key) ? $key : $value) will handle the following cases:
The text was updated successfully, but these errors were encountered: