graphql-python / graphql-python/graphene

non-reversible case conversion

オープン
#1,204 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
🐛 bug
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

説明

* **What is the current behavior?**
```python
>>> from graphene.utils.str_converters import to_snake_case
>>> from graphene.utils.str_converters import to_camel_case

>>> to_camel_case("my_variable_1")
'myVariable1'

>>> to_snake_case("myVariable1")
'my_variable1'
```

* **What is the expected behavior?**
```python
>>> from graphene.utils.str_converters import to_snake_case
>>> from graphene.utils.str_converters import to_camel_case

>>> to_camel_case("my_variable_1")
'myVariable1'

>>> to_snake_case("myVariable1")
'my_variable_1'
```

* **What is the motivation / use case for changing the behavior?**

Being able to convert objects/properties back and forth between server and client.
Also useful for introspecting and debugging use cases.

In my particular case, I receive an object on my server that the client got from the api and I want to associate it with the source which I now need an extra mapping for since the conversion is one-directional.

* **Please tell us about your environment:**

Version: graphene-django 2.10.0

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

This is where in graphene it is happening: https://github.com/graphql-python/graphene/issues/1204

My current workaround is to add an underscore in case of trailing numbers:
```python
input = re.sub(r'(.*)(\d+)$', r'\1_\2', input)
```

I have 2 solution suggestions:
1. Adding an underscore in case of trailing numbers.
2. Not removing the underscore in case of trailing numbers (like `_1`).

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

graphene.utils.str_converters から始め、文書化されている to_camel_case と to_snake_case の例を再現します。末尾の数値に対して提案されている2つの扱いを比較し、次に期待されるラウンドトリップ動作を定義して、変換によって最後の数値の前のアンダースコアが保持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。