Moodle

Named parameters must accept repetitions

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Not a bug
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Database SQL/XMLDB
  • Labels:
    None
  • Database:
    Any
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

When using named parameters... they should allow repetitions in the SQL, while being only specified once in the parameters array. It seems that isn't working right now.

http://moodle.org/mod/forum/discuss.php?d=102051

Ciao

Issue Links

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

Also... this should be functional-tested.

Show
Eloy Lafuente (stronk7) added a comment - Also... this should be functional-tested.
Hide
Petr Škoda (skodak) added a comment -

no, this is intentional because else you might override one parameter with another and not know it in long queries, sorry this is much safer

proposing keep as is

Show
Petr Škoda (skodak) added a comment - no, this is intentional because else you might override one parameter with another and not know it in long queries, sorry this is much safer proposing keep as is
Hide
Petr Škoda (skodak) added a comment -

now I remember, the sql standard does not allow this either
closing, not a bug

Show
Petr Škoda (skodak) added a comment - now I remember, the sql standard does not allow this either closing, not a bug
Hide
Eloy Lafuente (stronk7) added a comment -

Hi,

well, I agree about being possible to override them (by error) in long queries and so on, but also think it's possible (easier) to lose the order of "?" parameters (by error too), and that isn't preventing us to use them.

In any case (overridden named params or wrong order of ? params), it's a developer bug, like any other bug, and should be fixed. I don't see the "safer" point here really.

Also, talking about SQL standards... uhm... perhaps we should exclusively allow "?" parameters if we want to adhere 100% to it? If I don't remember wrong, from my old SQL sessions... question marks were the official ones.

I think I'll be using "?" all the time... but really the "repeated named ones" sound logic... unless some database driver forbids it. Although that can be bypassed by renaming params internally if necessary.

uhm, uhm...

Show
Eloy Lafuente (stronk7) added a comment - Hi, well, I agree about being possible to override them (by error) in long queries and so on, but also think it's possible (easier) to lose the order of "?" parameters (by error too), and that isn't preventing us to use them. In any case (overridden named params or wrong order of ? params), it's a developer bug, like any other bug, and should be fixed. I don't see the "safer" point here really. Also, talking about SQL standards... uhm... perhaps we should exclusively allow "?" parameters if we want to adhere 100% to it? If I don't remember wrong, from my old SQL sessions... question marks were the official ones. I think I'll be using "?" all the time... but really the "repeated named ones" sound logic... unless some database driver forbids it. Although that can be bypassed by renaming params internally if necessary. uhm, uhm...
Hide
Petr Škoda (skodak) added a comment -

pdo does not support this, sorry
the code detects wrong number of ? and the code detects incorrect use of :named params, the thing that needs improving is the debug message

Show
Petr Škoda (skodak) added a comment - pdo does not support this, sorry the code detects wrong number of ? and the code detects incorrect use of :named params, the thing that needs improving is the debug message

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: