Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json db doesn't respect dbName option on field #72

Open
noam-honig opened this issue May 31, 2022 · 3 comments
Open

Json db doesn't respect dbName option on field #72

noam-honig opened this issue May 31, 2022 · 3 comments
Assignees
Labels

Comments

@noam-honig
Copy link
Collaborator

Describe the bug
The dbName option of a field, works great in postgres and sql - but doesn't work when it comes to json db.
To Reproduce
Consider the following class:

@Entity("tasks", {
    allowApiCrud: true
})
export class Task {
    @Fields.uuid()
    id!: string;

    @Fields.string({dbName:'theTitle')
    title = '';

    @Fields.boolean()
    completed = false;
}

When the data is stored in the tasks.json file, the second field is stored as title and not theTitle

[
  {
    "id":"a",
    "title":"Task a"
  }
]

Expected behavior
it should be called theTitle in the json file:

[
  {
    "id":"a",
    "theTitle":"Task a"
  }
]

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

@Informagier
Copy link

Informagier commented Jul 14, 2022

I believe, the underlying cause is the ArrayEntityDataProvider

It just maps the column keys without checking the dbName

I will look deeper into it, when I have time :)

@Informagier
Copy link

Informagier commented Jul 20, 2022

Okay, sadly, I could not fix it and maybe these code snippets are unrelated to this bug

@noam-honig
Copy link
Collaborator Author

You're in the right place, you can take inspiration from the implementation of Mongo at:
https://github.com/remult/remult/blob/master/projects/core/remult-mongo.ts#L34

@noam-honig noam-honig self-assigned this Sep 26, 2023
noam-honig added a commit that referenced this issue Dec 11, 2023
* start work on relations

* Json db doesn't respect `dbName` option on field #72

* many to one based on it's own field - implemented

* a few more tests

* fixed another test

* Fixed test

* Moved Fields to a separate file

* helped support update etc... with many to one

* one to many started working

* added repository insert, count and find

* Added failing test

* added more testsw

* cleaned up tests

* replaced match with field

* removed limit from that api

* inherited from field options

* refactored to use regular repositories

* fixed test

* fixed include of many to one relation

* fixed to respect auto include and override

* fixed null etc

* fixed update

* made sure we get id

* included include in to and from json

* started

* refactored

* 🛑 added field reference and removed first parameter

* basic optimization

* progress on optimization

* more work on optimizations

* handled recursion fetch

* stabilized optimization

* more todos

* added internal export and fixed some typing and added types to index

* release 0.22.9-exp.0

* set new version number

* live query basics work

* added support for load in active record

* release 0.23.0-exp.1

* optional types options

* release 0.23.0-exp.2

* added support for query

* fixed load issue with older fileds

* fixed optional relation field issue

* more fixes

* improved typing

* more work on todo

* git this test to work

* more progress

* new way of defining id columns

* Added lifecycle events

* improved lifecycle events

* made second parameter for one mandatory

* Added thoughts

* made one work like reference

* merged reference with one

* renamed fields to relations

* release 0.23.0-exp.3

* updated changelog

* fixed readme

* release 0.23.0-exp.4

* more fix readme

* release 0.23.0-exp.5

* more tests

* release 0.23.0-exp.6

* mre readme work

* release 0.23.0-exp.7

* fixed readme

* saving row moved to backend

* Made progress on typing

* more typing work

* more typing

* fixed auto many to one relation - and exposed class type

* release 0.23.0-exp.8

* reduced in with one value to eq

* release 0.23.0-exp.9

* fixed relation bug

* release 0.23.0-exp.10

* fixed issue with sort

* release 0.23.0-exp.11

* Strip out "toMany" from GraphQL for now (#253)

* 🐛 FIX: strip out toMany from GraphQL for now

* 👌 FIX: code style

* more todo

* another exp

* release 0.23.0-exp.12

* 4564

* house keeping

* updated more stuff

* improved todo icons

* give error on missing field

* fixed lazy typing etc...

* a little more homework

* fixed toRawFilter

* fixed extra info on options

* release 0.23.0-exp.13

* fixed test

* release 0.23.0-exp.14

* update changelog

* stam commit

* Fixed typing issue

* release 0.23.0-exp.15

* Entity relations doc

* updated docs

* fixed index

* updated script

* 🚸 UPDATE: a few tweaks (#266)

* 🚸 UPDATE: a few tweaks

* Minor adjustments

* Item C

* applied JY comments

---------

Co-authored-by: Noam Honig <noam.honig@gmail.com>

* Fixed issue with updating of and related columns race

* release 0.23.0-exp.16

* Another null issue

* release 0.23.0-exp.17

* fixed another null issue

* release 0.23.0-exp.18

* Fixed typedoc markdown

* Updated docs

* minor doc update

* added comments

* udpated todo

* fixed included in api to be an expression

* fix

* release 0.23.0-exp.19

* fix sort

* release 0.23.0-exp.20

* fixed sort

* Fixed sort issue

* release 0.23.0-exp.21

* one more todo comment

* fixed compound id for svelte and added with remult

* release 0.23.0-exp.22

* one more minor issue

* release 0.23.0-exp.23

* 🎉 NEW: add offset arg in graphql on connection (#280)

* updates sveletkit tests

* release 0.23.0-exp.24

* more todos

* docs

* ⚡ NEW: ensure working also on non public schema (#288)

* apiRequireId returns 403 when using in Statement  #290

* release 0.23.0-exp.25

* fixed it only tests

* release 0.23.0-exp.26

* more notes

* Fixed equal to null issue

* release 0.23.0-exp.27

* More work

* updated todo

* ok

* More notes

* release 0.23.0-exp.28

* todo

* release 0.23.0-exp.29

* fixed update bug with compound id

* release 0.23.0-exp.30

* Fixed comment

* added lifecycle event to index

* release 0.23.0-exp.31

* update topics

* םל

* stabilized it

* added relations to docs

* another note

* todo

* fixed saving on field options

* added something interesting

* Removed use cache as default for findid

* Fixed typing issue

* Fixed db name

* updated todo

* update minor mongo db version

* update sqlite version

* fixed relation on change

* more progress

* more fix to todo

* fixed relation auto removal of data

* release 0.23.0-exp.32

* remult hapi supports crud

* updated the todo

* fixed a typing build error

* removed functions for fields etc...

* release 0.23.0-exp.33

* reverted omit functions

* release 0.23.0-exp.34

* Added hapi to change log and docs

* ok

* autocomplete with Relation.toOne

* demo problem

* compared api

* OmitFunctions

* TS hack for $ and _

* OmitFunctions

* aligned MembersOnly

* fixed package json

* release 0.23.0-exp.35

* Another note

* updated todo

* fixed _ $

* fixed null issue

* updated build

* release 0.23.0-exp.36

* finalized types

* release 0.23.0-exp.37

* fixed members only to exclude entity base

* release 0.23.0-exp.38

---------

Co-authored-by: JYC <jycouet@gmail.com>
Co-authored-by: Yoni Rapoport <yoni@fireflymigration.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants