MySQL Holy Parenthesis ... WTF



  • Trying to figure out an error in some code I inherited .. I came across this beautiful MySQL WHERE statement

    WHERE
    (((inventory_physical_detail.manual_Resolution) = 0
    and (inventory_physical_detail.system_Resolution) = 0)
    And ((inventory_physical_detail.Inventory_Physical_Header_ID) = 313.001 )
    and (inventory_physical_detail.Inventory_Items_Location_Number = 2 ))



  • Given that they're all the same operation, they're not needed, but it's not that bad, and I'd rather have too many parenthesis than too little.



  • Is that SQL auto-generated? I know that I've written a parser that would turn user-supplied search terms into a SOLR-friendly search query, and it produced similar results depending on the query given. Otherwise, that's just plain weird.



  • DEFF was not auto generated. :)



  • @jlego said:

    DEFF was not auto generated. :)

    Do me a favor then: find the guy who wrote it, and smack him upside his head for me, please. Who the eff puts parenthesis around column names? Sure, it works, but it's just silly.



  • @dohpaz42 said:

    @jlego said:
    DEFF was not auto generated. :)

    Do me a favor then: find the guy who wrote it, and smack him upside his head for me, please. Who the eff puts parenthesis around column names? Sure, it works, but it's just silly.

    As the original programmer must have finally realised by the time they got round to the final clause, by which inconsistency you can tell that it was probably not autogenerated.

     



  • unless he was being paid by the parenthesis...
    in which case, I want that job.



  • @dohpaz42 said:

    @jlego said:
    DEFF was not auto generated. :)

    Do me a favor then: find the guy who wrote it, and smack him upside his head for me, please. Who the eff puts parenthesis around column names? Sure, it works, but it's just silly.

    I've seen it consider...

     1) All names are delimited so thewy dont conflict with reserved words (often wtih [])
     2) Port to new DB with diffrent delimiters

     Safest thing to do is replace with parens...many are redundant, but none should harm...

    3) Confinue developing code without delimiters



  • This is what happens when you let the Lisp programmers write database code.



  • @tweek said:

    unless he was being paid by the parenthesis... in which case, I want that job to work in Lisp.

    FTFY!

     



  • @DaveK said:

    @tweek said:

    unless he was being paid by the parenthesis... in which case, I want that job to work in Lisp.

    FTFY!

     

    Beat me to it!

     


Log in to reply