datajoint / datajoint-python

Relational data pipelines for the science lab
https://datajoint.com/docs
GNU Lesser General Public License v2.1
169 stars 84 forks source link

FUNCTION datetime.date does not exist #172

Closed tstadler closed 8 years ago

tstadler commented 8 years ago

I get the following error message when I call populate() for a computed table where the ancestor table has a primary key of type date:

InternalError: (1630, "FUNCTION datetime.date does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual")

I could replicate it with a minimal example and have attached the schema and how I run it. I use an IPython Notebook for testing out schemas.

I could remove the error by giving exp_date the type varchar(20)

Example:

# The minimal example that creates the error
import datajoint as dj

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

@schema
class Basic(dj.Manual):
    definition="""
    exp_date    :date   # primary key with type date
    ---
    path        :varchar(20)    # variable used in Dependent
    """

@schema
class Dependent(dj.Computed):
    definition="""
    -> Basic
    ---
    new_path    :varchar(21)    # variable computed
    """

    def _make_tuples(self,key):
        p = (Basic() & key).fetch1['path']

        new_path = p + 'new'

        self.insert1(dict(key,new_path=new_path))

Run it:

# And how I run the file in an IPython Notebook
import datajoint as dj
import os

c = dj.conn()

%run sandbox.py

from sandbox import Basic
basic = Basic()
comp = Dependent()

basic.insert1({'exp_date':'2015-11-24','path':'example/path'})

comp.populate()

# For me it yields the following error:
# InternalError: (1630, "FUNCTION datetime.date does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual")
tstadler commented 8 years ago

Sry there was a typo in the schema! sandbox.txt

fabiansinz commented 8 years ago

I updated your comment so that we can see the code.

fabiansinz commented 8 years ago

I can reproduce the error and identified the cause. We'll discuss how to properly solve it and fix it.

tstadler commented 8 years ago

Great! Thanks

fabiansinz commented 8 years ago

Should be fixed by pull request #173 once it is accepted.