[web2py] Re: empty list:reference seems like a bug

2011-02-07 Thread Joe Barnhart
I just ran into a similar problem... I think.  I defined a
list:reference field like so:

Field(teams,list:reference team,label='Teams attending')

The problem is that after I inserted one record (with no entries in
the 'teams' field, I now get an error whenever I try to use the
database administrator on the table.  The exact error is BELONGS
takes exactly 3 arguments (2 given).

On digging further, it seems to be happening in SQLTABLE __init__, in
the fragment:

 elif field.represent:
r = field.represent(r)

Where r is None and the field is the list:reference field above.
There are no entries in the team table as of yet, so perhaps it is
returning None instead of an empty list.  I'll try entering some teams
next.

I'm still getting used to this WingIDE stuff, but it has vastly
extended my view of what's going on under the covers!

-- Joe B.

On Jan 28, 2:40 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Can you please try trunk?

 On Jan 28, 3:47 pm, LightOfMooN vladsale...@yandex.ru wrote:

  Running 1.91.6 too.

  db.define_table('tag',
      Field('name', 'string'), format='%(name)s')

  db.define_table('rolic',
      Field('name', 'string'),
      Field('tags', 'list:referencetag', required=True),
      )

  Add 1 rolic with empty tags, and database administration - db.rolic
  goes to error:
  ProgrammingError: syntax error at or near )
  LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());

  ERROR SNAPSHOT
  class 'psycopg2.ProgrammingError'(syntax error at or near )
  LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());
                                                    ^
  )

  On 29 янв, 00:09, DenesL denes1...@yahoo.ca wrote:

   I have a table with emptylist:referencefields and db admin does not
   have a problem with it.
   Running 1.91.6 .

   On Jan 28, 10:12 am, LightOfMooN vladsale...@yandex.ru wrote:

It's a problem, that if i have emptylist:reference, the standard
database administration don't work because of wrong query:

Traceback (most recent call last):
  File /home/www-data/web2py/gluon/restricted.py, line 188, in
restricted
    exec ccode in environment
  File /home/www-data/web2py/applications/funportal/views/
appadmin.html, line 191, in module
    p
  File /home/www-data/web2py/gluon/sqlhtml.py, line 1349, in
__init__
    r = field.represent(r)
  File /home/www-data/web2py/gluon/dal.py, line 3113, in
list_ref_repr
    refs = r._db(r.id.belongs(ids)).select(r.id)
  File /home/www-data/web2py/gluon/dal.py, line 4507, in select
    return self.db._adapter.select(self.query,fields,attributes)
  File /home/www-data/web2py/gluon/dal.py, line 1003, in select
    rows = response(sql)
  File /home/www-data/web2py/gluon/dal.py, line 994, in response
    self.execute(sql)
  File /home/www-data/web2py/gluon/dal.py, line 1067, in execute
    return self.log_execute(*a, **b)
  File /home/www-data/web2py/gluon/dal.py, line 1064, in log_execute
    return self.cursor.execute(*a,**b)
ProgrammingError: syntax error at or near )
LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());




[web2py] Re: empty list:reference seems like a bug

2011-02-07 Thread Joe Barnhart
OK, just as a hack, I changed the code in SQLTABLE from:

r = field.represent(r)

To:

r = field.represent(r or [])

This eliminates the crash in the database administrator due to the
list:reference field.  I hesitate to suggest this as a fix for the
issue because my understanding of this code is very superficial and
this may lead to unintended side effects.  There may be good reason to
pass 'None' to field.represent() under other circumstances.

-- Joe B.

On Feb 7, 10:38 pm, Joe  Barnhart joe.barnh...@gmail.com wrote:
 I just ran into a similar problem... I think.  I defined a
 list:reference field like so:

     Field(teams,list:reference team,label='Teams attending')

 The problem is that after I inserted one record (with no entries in
 the 'teams' field, I now get an error whenever I try to use the
 database administrator on the table.  The exact error is BELONGS
 takes exactly 3 arguments (2 given).

 On digging further, it seems to be happening in SQLTABLE __init__, in
 the fragment:

      elif field.represent:
         r = field.represent(r)

 Where r is None and the field is the list:reference field above.
 There are no entries in the team table as of yet, so perhaps it is
 returning None instead of an empty list.  I'll try entering some teams
 next.

 I'm still getting used to this WingIDE stuff, but it has vastly
 extended my view of what's going on under the covers!

 -- Joe B.



[web2py] Re: empty list:reference seems like a bug

2011-01-29 Thread LightOfMooN
I add this rolic using database administration - add rolic

On 29 янв, 03:07, DenesL denes1...@yahoo.ca wrote:
 On Jan 28, 4:47 pm, LightOfMooN vladsale...@yandex.ru wrote:

  Running 1.91.6 too.

  db.define_table('tag',
      Field('name', 'string'), format='%(name)s')

  db.define_table('rolic',
      Field('name', 'string'),
      Field('tags', 'list:reference tag', required=True),
      )

  Add 1 rolic with empty tags, and database administration - db.rolic

 How are you adding that rolic?
 It should not be possible with DAL since required=True.







  goes to error:
  ProgrammingError: syntax error at or near )
  LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());

  ERROR SNAPSHOT
  class 'psycopg2.ProgrammingError'(syntax error at or near )
  LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());
                                                    ^
  )


[web2py] Re: empty list:reference seems like a bug

2011-01-28 Thread DenesL

I have a table with empty list:reference fields and db admin does not
have a problem with it.
Running 1.91.6 .


On Jan 28, 10:12 am, LightOfMooN vladsale...@yandex.ru wrote:
 It's a problem, that if i have empty list:reference, the standard
 database administration don't work because of wrong query:

 Traceback (most recent call last):
   File /home/www-data/web2py/gluon/restricted.py, line 188, in
 restricted
     exec ccode in environment
   File /home/www-data/web2py/applications/funportal/views/
 appadmin.html, line 191, in module
     p
   File /home/www-data/web2py/gluon/sqlhtml.py, line 1349, in
 __init__
     r = field.represent(r)
   File /home/www-data/web2py/gluon/dal.py, line 3113, in
 list_ref_repr
     refs = r._db(r.id.belongs(ids)).select(r.id)
   File /home/www-data/web2py/gluon/dal.py, line 4507, in select
     return self.db._adapter.select(self.query,fields,attributes)
   File /home/www-data/web2py/gluon/dal.py, line 1003, in select
     rows = response(sql)
   File /home/www-data/web2py/gluon/dal.py, line 994, in response
     self.execute(sql)
   File /home/www-data/web2py/gluon/dal.py, line 1067, in execute
     return self.log_execute(*a, **b)
   File /home/www-data/web2py/gluon/dal.py, line 1064, in log_execute
     return self.cursor.execute(*a,**b)
 ProgrammingError: syntax error at or near )
 LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());


[web2py] Re: empty list:reference seems like a bug

2011-01-28 Thread LightOfMooN
Running 1.91.6 too.

db.define_table('tag',
Field('name', 'string'), format='%(name)s')

db.define_table('rolic',
Field('name', 'string'),
Field('tags', 'list:reference tag', required=True),
)

Add 1 rolic with empty tags, and database administration - db.rolic
goes to error:
ProgrammingError: syntax error at or near )
LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());

ERROR SNAPSHOT
class 'psycopg2.ProgrammingError'(syntax error at or near )
LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());
  ^
)


On 29 янв, 00:09, DenesL denes1...@yahoo.ca wrote:
 I have a table with empty list:reference fields and db admin does not
 have a problem with it.
 Running 1.91.6 .

 On Jan 28, 10:12 am, LightOfMooN vladsale...@yandex.ru wrote:







  It's a problem, that if i have empty list:reference, the standard
  database administration don't work because of wrong query:

  Traceback (most recent call last):
    File /home/www-data/web2py/gluon/restricted.py, line 188, in
  restricted
      exec ccode in environment
    File /home/www-data/web2py/applications/funportal/views/
  appadmin.html, line 191, in module
      p
    File /home/www-data/web2py/gluon/sqlhtml.py, line 1349, in
  __init__
      r = field.represent(r)
    File /home/www-data/web2py/gluon/dal.py, line 3113, in
  list_ref_repr
      refs = r._db(r.id.belongs(ids)).select(r.id)
    File /home/www-data/web2py/gluon/dal.py, line 4507, in select
      return self.db._adapter.select(self.query,fields,attributes)
    File /home/www-data/web2py/gluon/dal.py, line 1003, in select
      rows = response(sql)
    File /home/www-data/web2py/gluon/dal.py, line 994, in response
      self.execute(sql)
    File /home/www-data/web2py/gluon/dal.py, line 1067, in execute
      return self.log_execute(*a, **b)
    File /home/www-data/web2py/gluon/dal.py, line 1064, in log_execute
      return self.cursor.execute(*a,**b)
  ProgrammingError: syntax error at or near )
  LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());


[web2py] Re: empty list:reference seems like a bug

2011-01-28 Thread DenesL


On Jan 28, 4:47 pm, LightOfMooN vladsale...@yandex.ru wrote:
 Running 1.91.6 too.

 db.define_table('tag',
     Field('name', 'string'), format='%(name)s')

 db.define_table('rolic',
     Field('name', 'string'),
     Field('tags', 'list:reference tag', required=True),
     )

 Add 1 rolic with empty tags, and database administration - db.rolic

How are you adding that rolic?
It should not be possible with DAL since required=True.

 goes to error:
 ProgrammingError: syntax error at or near )
 LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());

 ERROR SNAPSHOT
 class 'psycopg2.ProgrammingError'(syntax error at or near )
 LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());
                                                   ^
 )


[web2py] Re: empty list:reference seems like a bug

2011-01-28 Thread Massimo Di Pierro
Can you please try trunk?

On Jan 28, 3:47 pm, LightOfMooN vladsale...@yandex.ru wrote:
 Running 1.91.6 too.

 db.define_table('tag',
     Field('name', 'string'), format='%(name)s')

 db.define_table('rolic',
     Field('name', 'string'),
     Field('tags', 'list:reference tag', required=True),
     )

 Add 1 rolic with empty tags, and database administration - db.rolic
 goes to error:
 ProgrammingError: syntax error at or near )
 LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());

 ERROR SNAPSHOT
 class 'psycopg2.ProgrammingError'(syntax error at or near )
 LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());
                                                   ^
 )

 On 29 янв, 00:09, DenesL denes1...@yahoo.ca wrote:







  I have a table with empty list:reference fields and db admin does not
  have a problem with it.
  Running 1.91.6 .

  On Jan 28, 10:12 am, LightOfMooN vladsale...@yandex.ru wrote:

   It's a problem, that if i have empty list:reference, the standard
   database administration don't work because of wrong query:

   Traceback (most recent call last):
     File /home/www-data/web2py/gluon/restricted.py, line 188, in
   restricted
       exec ccode in environment
     File /home/www-data/web2py/applications/funportal/views/
   appadmin.html, line 191, in module
       p
     File /home/www-data/web2py/gluon/sqlhtml.py, line 1349, in
   __init__
       r = field.represent(r)
     File /home/www-data/web2py/gluon/dal.py, line 3113, in
   list_ref_repr
       refs = r._db(r.id.belongs(ids)).select(r.id)
     File /home/www-data/web2py/gluon/dal.py, line 4507, in select
       return self.db._adapter.select(self.query,fields,attributes)
     File /home/www-data/web2py/gluon/dal.py, line 1003, in select
       rows = response(sql)
     File /home/www-data/web2py/gluon/dal.py, line 994, in response
       self.execute(sql)
     File /home/www-data/web2py/gluon/dal.py, line 1067, in execute
       return self.log_execute(*a, **b)
     File /home/www-data/web2py/gluon/dal.py, line 1064, in log_execute
       return self.cursor.execute(*a,**b)
   ProgrammingError: syntax error at or near )
   LINE 1: SELECT  tag.id FROM tag WHERE (tag.id IN ());