1. Indeed, a tuple is needed so in Python the trailing comma in (1,) is important. I like your suggestion of raising an error if (1) is passed - I'll add it to the todo list.
2. It would help if you use a consistent way of naming the heading attributes. I tend to use Pascal case, but I don't think it's something that should be enforced or matched case-insensitively since Python is case sensitive with its names. Perhaps some kind of pre-parser, or maybe a verbose-checking-mode, to check the sanity of a schema or set of expressions would be useful. This could spot mis-spellings, and joins where the column names were probably meant to match but didn't, and unintended cartesian joins etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I started playing around with Dee and have two reflections.
1. If I create a relation like:
>>> from Dee import *
>>> X = Relation(['A'],[(1)])
>>> X
Relation(('A',),
[],
{'PK':(Key, None)})
I.e. it has no body. I would have expected X to look like:
>>> X
Relation(('A'),
[Tuple(A=1)],
{'PK':(Key, None)})
Is it intended this way?
2. Do you think it would be a good idea to always store the heading in upper (or lower) case? I.e.
>>> X = Relation(['A','b'],[(1,1)])
>>> Y = Relation(['a','B'],[(1,1)])
>>> X==Y
True
I can imagine some confusion in a situation like:
>>> Student = Relation(['StudentId', 'Whatever'],[(1,'a'),(2,'b')])
>>> Mark = Relation(['Studentid','Mark'],[(1,'G')])
>>> Student & Mark
Relation(('Studentid', 'StudentId', 'Whatever', 'Mark'),
[Tuple(Studentid=1, StudentId=1, Whatever='a', Mark='G'), Tuple(Studentid=1, StudentId=2, Whatever='b', Mark='G')],
{'PK':(Key, None)})
Regards
/Lennart
Ah, yes. One has to use a tuple. Silly me :-)
>>> X = Relation(['A'],[(1,)])
>>> X
Relation(('A',),
[Tuple(A=1)],
{'PK':(Key, None)})
Perhaps it would be a good idea to throw an error in the case of:
>>> X = Relation(['A'],[(1)])
>>> X
Relation(('A',),
[],
{'PK':(Key, None)})
Regards
/Lennart
1. Indeed, a tuple is needed so in Python the trailing comma in (1,) is important. I like your suggestion of raising an error if (1) is passed - I'll add it to the todo list.
2. It would help if you use a consistent way of naming the heading attributes. I tend to use Pascal case, but I don't think it's something that should be enforced or matched case-insensitively since Python is case sensitive with its names. Perhaps some kind of pre-parser, or maybe a verbose-checking-mode, to check the sanity of a schema or set of expressions would be useful. This could spot mis-spellings, and joins where the column names were probably meant to match but didn't, and unintended cartesian joins etc.