import modes not working for write operations
- Dominant language
- Python
- Stars
- 14
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
code snippet to reproduce:
via doltcli
`write_rows(write_rows(dolt, "characters", TEST_ROWS, REPLACE, ["id"])`
or via doltpy:
`write_pandas(dolt, table_name, df, import_mode='replace')`
both call `_import_helper` which refers to
https://github.com/dolthub/doltcli/blob/a807c93d01d2f76beb0260a76a8bd58a40b1c7ad/doltcli/utils.py#L251-L265
the checks force it to return only `create/update` mode depending on the existence of the table, `replace/force-create` modes are ignored
suggested change (MR #32 ) :
```
def _get_import_mode_and_flags(
dolt: DoltT, table: str, import_mode: Optional[str] = None
) -> str:
import_modes = IMPORT_MODES_TO_FLAGS.keys()
if import_mode and import_mode not in import_modes:
raise ValueError(f"update_mode must be one of: {import_modes}")
elif import_mode:
return import_mode
else:
if table in [table.name for table in dolt.ls()] and import_mode :
logger.info(f'No import mode specified, table exists, using "{UPDATE}"')
import_mode = UPDATE
else:
logger.info(f'No import mode specified, table exists, using "{CREATE}"')
import_mode = CREATE
return import_mode
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.