Closed leafonsword closed 6 years ago
I just stumbled across the same error. Looking at the relevant code part, it seems that raising this exception is the intended behaviour of first()
whenever there are >1 rows. See: https://github.com/kennethreitz/records/blob/master/records.py#L205
@kennethreitz I feel like this is a bad naming choice. Given the wording, i would expect first()
to give me the first element, regardless of how many rows have been returned by ther query. Perhaps introduce something like one()
that returns exactly one row or raises a exception if >1 rows are retreived.
Otherwise, great library. Keep it up.
Coming from a .NET background this weirded me out a bit too. I'm used to first()
returning the first item of a sequence of any length, while single()
ensures that there is also only one item.
Sqlalchemy has first()
return the first row (although it also does a limit 1) and uses one()
to return and enforce.
I think I'd go for the sqlalchemy naming convention (first/one), since thats more closely python related :snake:
Resolved by PR #127
Thanks guys!
But this table just contains 13 rows