pocketbase icon indicating copy to clipboard operation
pocketbase copied to clipboard

camelCase Row names become snake_case

Open maksp-glitch opened this issue 1 year ago • 2 comments

I just started using the Pocketbase Python SDK for a machine learning tool i wanna build.

The Python SDK returns me an Record Model which i convert with vars(search_requests_record) to a dict. Then i stumbled upon the fact, that the python SDK gives me all my camelCase row names in snake_case back.

This is a real issue since all my pd.DataFrame checks have been written to fit the selected row names. Now i need to redo everything.

How come it converts to snake_case?

maksp-glitch avatar Aug 14 '24 09:08 maksp-glitch

It seems to be by choice. There is a helper method in the utils module and in the load function of a record it gets applied.

I think this should not be the default case, as it seems to bring in inconsistencies between extracting and loading data. It seems a little opinionated to me, I'd much rather have it activated with some kind of kwarg in a function than be the default.

hannesknoll avatar Mar 15 '25 17:03 hannesknoll

I shouldn't even have to point out how problematic this behavior is. It might come from a well-intentioned idea of making the Python code more "pythonic" by converting to snake_case, but PocketBase is a language-agnostic technology used across different environments. Forcing a camelCase to snake_case transformation breaks consistency with the original API and can obviously lead to bugs or confusion.

At the very least, this behavior should be clearly documented and optional via a setting. Silently transforming data from a backend without giving users control is not good practice, even if it aims to follow Python conventions.

Edit: I just push a PR #123

antharuu avatar Jun 25 '25 09:06 antharuu