datajoint / datajoint-matlab

Relational data pipelines for the science lab
MIT License
42 stars 38 forks source link

Error in restriction of projection of restriction #44

Open eywalker opened 9 years ago

eywalker commented 9 years ago

Restricting a project of restricted table yields an error due to incorrect MySQL syntax.

For example,

pro(acq.Sessions & 'subject_id = 1') & 'subject_id = 1'

produces an error: Error using mym You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (subject_id = 1) LIMIT 1) as yes' at line 1

Surely enough, checking the SQL query produced via above operation yields:

`acq`.`sessions` WHERE (subject_id = 1) WHERE (subject_id = 1)
fabiansinz commented 9 years ago

Similar example

import datajoint as dj

schema = dj.schema('datajoint_bug', locals())

@schema
class Subject(dj.Lookup):
    definition = """
    id                  : int # subject id
    ---
    name                : varchar(40) # real name
    """

    contents = [(0,'Edgar'), (1, 'Dimitri'), (2, 'Fabian')]

rel =  ((Subject() & 'id=0').project() & 'id=0')
print(rel.make_select())

works correctly in python. It produces the SQL statement

'SELECT `id` FROM `datajoint_bug`.`#subject` WHERE (id=0)'
eywalker commented 7 years ago

Is this fixed?