Skip to content
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

Single quotes in queries handled incorrectly in convert.php #39

Open
GuyPaddock opened this issue Nov 27, 2013 · 0 comments
Open

Single quotes in queries handled incorrectly in convert.php #39

GuyPaddock opened this issue Nov 27, 2013 · 0 comments

Comments

@GuyPaddock
Copy link

This was the input query:

    SELECT   work_share_round_ref.field_share_round_nid                                     AS `round_nid`,
             work_share_submitter.field_share_submitter_uid                                 AS `user_uid`,
             MIN(work_share_difficulty.field_share_difficulty_value)                        AS `user_round_min_difficulty`,
             COUNT(1)                                                                       AS `user_round_share_count`

    FROM     node                                       AS `node_work_share`

    JOIN     field_data_field_share_round               AS `work_share_round_ref`
    ON       node_work_share.nid               = work_share_round_ref.entity_id
       AND   work_share_round_ref.entity_type  = 'node'
       AND   work_share_round_ref.deleted      = 0

    JOIN     field_data_field_share_difficulty          AS `work_share_difficulty`
    ON       node_work_share.nid               = work_share_difficulty.entity_id
       AND   work_share_difficulty.entity_type = 'node'
       AND   work_share_difficulty.deleted     = 0

    JOIN     field_data_field_share_submitter           AS `work_share_submitter`
    ON       node_work_share.nid               = work_share_submitter.entity_id
       AND   work_share_difficulty.entity_type = 'node'
       AND   work_share_difficulty.deleted     = 0

    JOIN     field_data_field_share_verified_by_pool    AS `work_share_verified`
    ON       node_work_share.nid               = work_share_verified.entity_id
       AND   work_share_difficulty.entity_type = 'node'
       AND   work_share_difficulty.deleted     = 0

    WHERE    node_work_share.type                                   = 'share'
       AND   node_work_share.status                                 = 1
       AND   work_share_verified.field_share_verified_by_pool_value = 1

    GROUP BY round_nid, user_uid

This resulted in the following output from convert:

CALL flexviews.create('theredpool_drupal', '', 'INCREMENTAL');
SET @mvid := LAST_INSERT_ID();
CALL flexviews.add_expr(@mvid,'GROUP','work_share_round_ref.field_share_round_nid','round_nid');
CALL flexviews.add_expr(@mvid,'GROUP','work_share_submitter.field_share_submitter_uid','user_uid');
CALL flexviews.add_expr(@mvid,'MIN','work_share_difficulty.field_share_difficulty_value','user_round_min_difficulty');
CALL flexviews.add_expr(@mvid,'COUNT','1','user_round_share_count');

CALL flexviews.add_table(@mvid,'theredpool_drupal','node','node_work_share',NULL);
CALL flexviews.add_table(@mvid,'theredpool_drupal','field_data_field_share_round','work_share_round_ref','ON node_work_share.nid = work_share_round_ref.entity_id AND work_share_round_ref.entity_type = \'\'node\'\' AND work_share_round_ref.deleted = 0');
CALL flexviews.add_table(@mvid,'theredpool_drupal','field_data_field_share_difficulty','work_share_difficulty','ON node_work_share.nid = work_share_difficulty.entity_id AND work_share_difficulty.entity_type = \'\'node\'\' AND work_share_difficulty.deleted = 0');
CALL flexviews.add_table(@mvid,'theredpool_drupal','field_data_field_share_submitter','work_share_submitter','ON node_work_share.nid = work_share_submitter.entity_id AND work_share_difficulty.entity_type = \'\'node\'\' AND work_share_difficulty.deleted = 0');
CALL flexviews.add_table(@mvid,'theredpool_drupal','field_data_field_share_verified_by_pool','work_share_verified','ON node_work_share.nid = work_share_verified.entity_id AND work_share_difficulty.entity_type = \'\'node\'\' AND work_share_difficulty.deleted = 0');
CALL flexviews.add_expr(@mvid,'WHERE','node_work_share.type = \'\' \'\' AND node_work_share.status = 1 AND work_share_verified.field_share_verified_by_pool_value = 1','where_clause');
CALL flexviews.enable(@mvid);

Three issues:

  1. Why does the convert script not take an MV name parameter on the command line? I always forget to fill in the name on the first line of the output.
  2. Each single-quoted string is over-quoted (i.e. ' turns into '' instead of ').
  3. The first single-quoted string in the WHERE clause is completely dropped.

If I change to double-quoted strings, 2 and 3 are no longer issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants