Code Monkey home page Code Monkey logo

Comments (6)

allejo avatar allejo commented on June 27, 2024

The spaces in the "AS" clauses is confirmed

While trying the case "Not all column names must have an alias", the column given without alias are generated like origin AS , file_type AS, year as publication_year instead of origin, file_type, year as publication_year

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;

from phpsoda.

shravass avatar shravass commented on June 27, 2024

Hi,
Thank you for your immediate response.

With respect to point 2:
We are actually using a YAML SQL file and we parse the YAML file using symfony https://symfony.com/doc/current/components/yaml/yaml_format.html

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.

from phpsoda.

allejo avatar allejo commented on June 27, 2024

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

from phpsoda.

shravass avatar shravass commented on June 27, 2024

It generates the following array formats:

  1. array( "value", "value", "value");
  2. array("key" => "value" , "key" => "value");
  3. array("key" => null, "key" => "value");

We tried the combination of array("key" => "value" , "value") but Symfony is not able to recognize this format.

from phpsoda.

allejo avatar allejo commented on June 27, 2024

Ah, that makes sense. In your PR, could you do the following and I'll merge it in:

  1. Add unit tests to test against both array structures:

    array(
      "origin",
      "file_type",
      "year" => "publication_year"
    );

    and

    array(
      "origin" => null,
      "file_type" => null,
      "year" => "publication_year"
    );
  2. Split up the nested ternaries into an if statement. Something like this?

    if (is_string($key) && !is_null($value))
    {
        $formattedValues[] = rawurlencode(sprintf($format, trim($key), trim($value)));
    }
    else
    {
        $formattedValues[] = is_string($key) ? $key : $value;
    }

from phpsoda.

shravass avatar shravass commented on June 27, 2024

I have completed the above. Hope the test cases are fine.
Thanks

from phpsoda.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.