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

#4476 breaks non-object simple-json columns #5116

Closed
svvac opened this issue Nov 20, 2019 · 2 comments
Closed

#4476 breaks non-object simple-json columns #5116

svvac opened this issue Nov 20, 2019 · 2 comments

Comments

@svvac
Copy link

svvac commented Nov 20, 2019

Bug report for 0.2.20 (MySQL/MariaDB, but it probably is backend-independent)

This added check in PR #4476 forbids using simple-json columns with non-object values as it defaults to returning an empty object if the parsed value is not an object.

This breaks existing models that support e.g. string or number values in such a column.

@Entity()
class ConfigValue {
    @PrimaryColumn()
    public key: string;

    @Column('simple-json')
    public value: any;
}

async function test (connection) {
    const repo = connection.getRepository(ConfigValue);
    const config = new ConfigValue({ key: 'numeric config', value: 42 })
    await repo.save(config);
    const read = await repo.findOne('numeric config');
    assert(read.value === 42); // fails
}
@svvac
Copy link
Author

svvac commented Nov 21, 2019

See PR #5125

@imnotjames
Copy link
Contributor

Separate PR merged. This will be fixed in next release.

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

2 participants