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

PUT does not update associated tables #194

Open
danvk opened this issue Nov 1, 2016 · 1 comment
Open

PUT does not update associated tables #194

danvk opened this issue Nov 1, 2016 · 1 comment

Comments

@danvk
Copy link

danvk commented Nov 1, 2016

I'm trying to use PUT to update a model with associations.

I have a Map model which HasMany Layers. Map 4 has one layer in the DB. map.json specifies two layers.

When I use PUT to update map 4, the request succeeds and returns a modified Map:

$ http PUT localhost:1337/object/map/4 < map.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 514
Content-Type: application/json; charset=utf-8
Date: Tue, 01 Nov 2016 19:03:54 GMT
ETag: W/"202-avvKiF6AQG/hPzW3CJAakQ"
X-Powered-By: Express

{
    "author": "danvk",
    "baseMapStyle": "{}",
    "createdAt": "2016-11-01T16:05:30.086Z",
    "description": "This map has two layers",
    "id": 4,
    "lat": 43.22,
    "layer": [
        {
            "config": "config = {}",
            "description": "It's a really great layer, trust me.",
            "name": "My layer",
            "sqlQuery": "SELECT * FROM dataset",
            "zIndex": 0
        },
        {
            "config": "config = {}",
            "description": "It's an even better layer, trust me.",
            "name": "My layer",
            "sqlQuery": "SELECT * FROM dataset",
            "zIndex": 1
        }
    ],
    "lng": -137.22,
    "name": "My Map",
    "updatedAt": "2016-11-01T19:03:54.447Z",
    "zoomLevel": 12
}

A subsequent GET, however, shows that the new data wasn't written to the database:

$ http GET localhost:1337/object/map/4                
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 744
Content-Type: application/json; charset=utf-8
Date: Tue, 01 Nov 2016 19:12:39 GMT
ETag: W/"2e8-bsUeBJOAcTqI1e8ugkbqpg"
X-Powered-By: Express

{
    "author": "danvk",
    "baseMapStyle": "{}",
    "createdAt": "2016-11-01T16:05:30.086Z",
    "description": "This map has two layers",
    "id": 4,
    "lat": 43.22,
    "layer": [
        {
            "SavedMapId": 4,
            "createdAt": "2016-11-01T16:05:30.123Z",
            "description": null,
            "id": 3,
            "name": "Untitled Layer",
            "sqlQuery": "SELECT *\nFROM blah",
            "updatedAt": "2016-11-01T16:05:30.123Z",
            "zIndex": 1
        }
    ],
    "lng": -137.22,
    "name": "My Map",
    "updatedAt": "2016-11-01T19:03:54.447Z",
    "zoomLevel": 12
}

I'm running from HEAD using Postgres.

@danvk
Copy link
Author

danvk commented Nov 1, 2016

cc @asmodehn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant