0

I am populating a database and I have these this model:

class Album(StructuredNode):
    name = StringProperty(unique_index=False, required=True)
    artist = StringProperty(unique_index=False, required=True)
    slug = StringProperty(unique_index=True, required=True)

But for some reason when I try to populate my database, if I have two albums with the same name but different artists and slugs, I get this error:

File "/Users/datascientist/Desktop/populate.py", line 66, in <module>
  album.save()   
File "/Users/datascientist/anaconda/lib/python2.7/site-packages/neomodel/signals.py", line 25, in hooked
  val = fn(self, *args, **kwargs)
File "/Users/datascientist/anaconda/lib/python2.7/site-packages/neomodel/core.py", line 159, in save
  self._id = self.create(self.__properties__)[0]._id
File "/Users/datascientist/anaconda/lib/python2.7/site-packages/neomodel/core.py", line 289, in create
  results = db.cypher_query(query, params)
File "/Users/datascientist/anaconda/lib/python2.7/site-packages/neomodel/util.py", line 216, in cypher_query
  raise UniqueProperty(e.message)

neomodel.exception.UniqueProperty

How do I make it so the name parameter isn't unique?

Rob
  • 3,333
  • 5
  • 28
  • 71
  • I realize that combining album and artist into a single line like ("album" + " ..... " + artist) would work, but I'd like to know a more appropriate solution – Rob Sep 28 '15 at 22:21
  • That error might be expected if you are trying to create multiple albums with the same `slug` value, since `slug` is declared to be unique. Are you sure that you are not trying to do that? – cybersam Sep 28 '15 at 23:24
  • slug is supposed to be unique and it is, the problem is when album is the same as another, like many albums have the same title. The slug is album-artist so it is never the same as another. – Rob Sep 29 '15 at 01:51
  • So, if an artist re-releases an album (say, after remastering), it is guaranteed to have a new name? – cybersam Sep 29 '15 at 01:52
  • yes, according to my database. Either way, the error is being thrown in a specific instance where they have different artists and slugs but the same name. – Rob Sep 29 '15 at 17:10

0 Answers0