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

Unable to use method named as attributes( ) in a model. #2109

Open
akashgp09 opened this issue Jun 11, 2021 · 0 comments
Open

Unable to use method named as attributes( ) in a model. #2109

akashgp09 opened this issue Jun 11, 2021 · 0 comments

Comments

@akashgp09
Copy link

akashgp09 commented Jun 11, 2021

Introduction

Unable to use method/property named as attributes( ) in a Model.

Issue Description

export default function relationshipAttributeSet(bookshelf) {
	const RelationshipAttributeSet = bookshelf.Model.extend({
		attributes() {
			return this.belongsToMany(
				'RelationshipAttribute', 'bookbrainz.relationship_attribute_set__relationship_attribute',
				'set_id', 'attribute_id'
			);
		},
		format: camelToSnake,
		idAttribute: 'id',
		parse: snakeToCamel,
		tableName: 'bookbrainz.relationship_attribute_set'
	});

	return bookshelf.model('RelationshipAttributeSet', RelationshipAttributeSet);
}

Consider the above Model. It has a method attributes( ). When I try to use this method it throws Error: attributes is not defined on the model. If I change the method name from attributes( ) to any other name it works fine.

Expected behaviour

Should not throw any error If a method is named as attributes( )

Actual behaviour

Throws Error: attributes is not defined on the model
Cannot use method defined as attributes( ) in a Model.

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