-
Alex authored
This is a bit of a nitpick, but say you do this: ```ruby user.as_json(only: [:email, :name]).keys ``` The result will depend on the order that the columns were added to your database (or in a test environment, the order of the columns in your `structure.sql`). ie. you might get `["email", "name"]` or `["name", "email"]`. In the specific case that you've provided `only` you are being explicit about which fields should be returned, so we can also be explicit about the order that they are returned in. This PR implements that. Now it will always return fields based on the order they're provided to the `only` argument, so in this case it would always be `["email", "name"]`. Co-authored-by:
John Hawthorn <john@hawthorn.email>
Alex authoredThis is a bit of a nitpick, but say you do this: ```ruby user.as_json(only: [:email, :name]).keys ``` The result will depend on the order that the columns were added to your database (or in a test environment, the order of the columns in your `structure.sql`). ie. you might get `["email", "name"]` or `["name", "email"]`. In the specific case that you've provided `only` you are being explicit about which fields should be returned, so we can also be explicit about the order that they are returned in. This PR implements that. Now it will always return fields based on the order they're provided to the `only` argument, so in this case it would always be `["email", "name"]`. Co-authored-by:
John Hawthorn <john@hawthorn.email>
Loading