Uh oh!
There was an error while loading. Please reload this page.
Add 'Table.row_from_mapping' helper. - #3425
Conversation
dhermes
left a comment
There was a problem hiding this comment.
I wouldn't say this "closes #3396". That asks us to accept dictionaries in insert_data.
We should either:
- Explicitly not support it (i.e. either a blacklist or whitelist of types)
- Accept a polymorphic input (I am not really into that)
- Offer a sibling
insert_data_from_mappings(or a better / shorter name)
| :rtype: tuple | ||
| :returns: Tuple matching the table's schema | ||
| :raises: ValueError if table's schema is not set |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| :param mapping: Mapping of row data. | ||
| :rtype: tuple | ||
| :returns: Tuple matching the table's schema |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| row.append(mapping[field.name]) | ||
| elif field.mode == 'REPEATED': | ||
| row.append(mapping.get(field.name, ())) | ||
| else: # NULLABLE |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| row.append(mapping.get(field.name, ())) | ||
| else: # NULLABLE | ||
| row.append(mapping.get(field.name)) | ||
| return tuple(row) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| with self.assertRaises(ValueError) as exc: | ||
| table.row_from_mapping(MAPPING) | ||
| self.assertEqual(exc.exception.args, (_TABLE_HAS_NO_SCHEMA,)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
tseaver
commented
May 17, 2017
Given a table.insert_data([table.row_from_mapping(mapping) formappinginmapping_list])I'm proposing closing #3396 with a note to that effect. |
lukesneeringer
commented
Aug 7, 2017
dhermes
commented
Aug 7, 2017
If LGTY @lukesneeringer then I'm OK with it |
Closes#3396.