Adrian Klaver wrote:
> Thanks for the clarification. Any chance addFieldsFromDataStructure() will 
> make it into the general code? If not I will code something up here. 

I guess we could provide a basic implementation for you to call from your 
bizobj 
code. Here's my version that has extra stuff because I like my SQL to be 
formatted 
with the "proper" amount of space indentation on each line:

  34   def addFieldsFromDataStructure(self):
  35     max_fill = 0
  36     for field in self.DataStructure:
  37       if field[3] is not None:
  38         fill = len("%s.%s" % (field[3], field[4]))
  39         max_fill = max(max_fill, fill)
  40     for field in self.DataStructure:
  41       fill = " " * (max_fill - len("%s.%s" % (field[3], field[4])))
  42       if field[3] is not None:
  43         self.addField("%s.%s %sas %s" % (field[3], field[4], fill, 
field[0]))



> Invoking UserSQL overrides the SQL Builder methods in dCursorMixin.py.

Yep! And it has some side-effects too, but I'm hard-pressed to remember what 
they are 
now. Something to do with child bizobjs not getting requeried with their parent?


>   This means you lose any parent-child relationship information set in a 
> bizobj

Yep. Although I'm still not convinced that it has to be that way, but I haven't 
had 
the time to dig.


> As noted DataStructure lives outside the SQL Builder

Yes.

> A dataset starts out as tuple of dictionaries. 

Yes.

> When getDataSet() is called you get a sqlite3 table that can be used in 
> queries by using the alias "dataset".

No, you get a dDataSet instance, which is a subclass of tuple, whose items are 
dictionaries. This tuple, a dDataSet instance, has extra functionality to let 
you 
call execute() on it using the "dataset" alias which will return another 
dDataSet 
instance.

The fact that there's some in-memory sqlite3 stuff in the implementation 
shouldn't 
really concern you as a user, other than you may need to know some sqlite 
syntax quirks.

> Doing bizobj.filter() sets up a sqlite3 dataset.

Yes.

> sqlite3 does not understand timestamps with time zones. 

sqlite only really knows about INT and CHAR. pysqlite knows about some but not 
all 
extra types like dates, times, etc.

> This is what initially led to all this. I tried to bizobj.filter() and the 
> dataset choked on a timestamp field I did not think I had included in my 
> bizobj. 

Can you post the traceback?

> This a is an issue with sqlite/pysqlite they will INSERT a string with a time 
> zone offset but will error on retrieving  it. 

Can you post the error?


> Now that I understand DataStructure, it is not problem. Something to deal 
> with at another time.

Okay.

Paul

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to