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

UNIQUE #967

Open
crysan opened this issue Mar 16, 2015 · 52 comments
Open

UNIQUE #967

crysan opened this issue Mar 16, 2015 · 52 comments

Comments

@crysan
Copy link

crysan commented Mar 16, 2015

How to determine the class that the field name unique? Just as Primary keys?

@emanuelez
Copy link
Contributor

Yes, so far that's the only way, but we're considering to support some kind of annotation for field value uniqueness

@cmelchior
Copy link
Contributor

Just to be curious. Do you have a use case for this that isn't already covered by using @PrimaryKey?

@crysan
Copy link
Author

crysan commented Mar 18, 2015

The problem was solved. Only after the introduction of a unique field in the table, we had to alter the program logic.
There were:
realm.beginTransaction();
Authors author = realm.createObject(Authors.class);
author.setUrl_base("pptr");
realm.commitTransaction();
Now:
Authors author = new Authors();
author.setUrl_base("pptr");
realm.beginTransaction();
realm.copyToRealmOrUpdate(author);
realm.commitTransaction();
Very unfortunate that because of one field had to rewrite the code.

@emanuelez
Copy link
Contributor

That happens because you don't set your unique field. If you did you would not have to use standalone objects

@crysan
Copy link
Author

crysan commented Mar 19, 2015

Ok.

@mclark4386
Copy link

@emanuelez sorry I'm confused, would you mind giving a little code snippet of what you are talking about?

@crysan
Copy link
Author

crysan commented Mar 19, 2015

But I cited above code that used prior to the introduction to the table a unique field, and after it. Now you have to write one line of code to add more new rows to a table.

@cmelchior cmelchior added the P1 label Apr 15, 2015
@cmelchior cmelchior added P2 Blocked This issue is blocked by another issue and removed P1 labels Apr 23, 2015
@beeender beeender removed the Blocked This issue is blocked by another issue label Jul 8, 2015
@cmelchior
Copy link
Contributor

SQLite also has different modes for conflict resolution when it comes to uniqueness constraints we can consider: https://www.sqlite.org/lang_conflict.html

@tarigancana
Copy link

👍 waiting for this enhancement :)

@AlokBansal8
Copy link

@beeender @cmelchior Is this feature coming anytime soon?

@wyvern610
Copy link

Realm is lacking important feature. realm even has no compound key. so we have to calculate compound key manually.so in practical development, realm is useless.
Realm has no roadmap.so don't expect anything.

@Zhuinden
Copy link
Contributor

Zhuinden commented Sep 23, 2016

@cmelchior now that Primary Keys also imply that the value cannot be changed once persisted, is there a chance for a @Unique constraint which doesn't force you into the "value cannot be changed once persisted" limitation?

@mfissehaye
Copy link

+1

3 similar comments
@2mwrzesinsky
Copy link

+1

@the-dr-lazy
Copy link

+1

@YaroslavYrm
Copy link

+1

@lednhatkhanh
Copy link

Any news on this, I'm still waiting for this feature

@shobhitpuri
Copy link

+1

@dtmandroid
Copy link

I want to make field 'itemName' of Table Item to be unique in Android Realm. It means 'itemName' should not contain duplicate values. Is there any other way to achieve this except Primary key.. Thanks..

@ScheNi
Copy link

ScheNi commented May 11, 2017

+1

@rudysuharyadi
Copy link

+1, and i need it on realm-cocoa too.

@Ramzi-Alqrainy
Copy link

+1

2 similar comments
@mblsha
Copy link

mblsha commented Mar 5, 2018

+1

@vzool
Copy link

vzool commented Mar 21, 2018

+1

@luben93
Copy link

luben93 commented Jun 19, 2018

+1

@Zhuinden
Copy link
Contributor

just for sake of completion, apparently ObjectBox 2.0 added @Unique: https://objectbox.io/objectbox-2-0/

@vzool
Copy link

vzool commented Jul 25, 2018

@Zhuinden This is ObjectBox not Realm! Are they the same?

@Zhuinden
Copy link
Contributor

Zhuinden commented Jul 25, 2018

No, they are two completely different products from two completely different companies.

To be honest, I'm not fond of ObjectBox's migration scheme, so I'm not using it; but they are working on the same domain as Realm. So it makes sense that Realm should be aware of competition.

@JonathanImperato
Copy link

+1

@Abdelsattar
Copy link

+1 too

@him2016
Copy link

him2016 commented Feb 14, 2019

+1

@LunevNF
Copy link

LunevNF commented Feb 28, 2019

Unique two fields - when?

@dyegos
Copy link

dyegos commented Mar 12, 2019

+1

1 similar comment
@JohannesJoestar
Copy link

+1

@charlykno64
Copy link

+1

@maikotrindade
Copy link

+1
2020

@Romancha
Copy link

+1

@anthony-alekseiev
Copy link

+1

@cmelchior cmelchior added the Blocked This issue is blocked by another issue label Aug 20, 2020
@RealmBot RealmBot removed the Blocked This issue is blocked by another issue label Sep 24, 2020
@lukluca
Copy link

lukluca commented Dec 4, 2020

+1

@jaredmdobson
Copy link

@yell66w
Copy link

yell66w commented Feb 27, 2023

+1

2 similar comments
@ksanderer
Copy link

+1

@mancioshell
Copy link

+1

@hkchakladar
Copy link

Is there any roadmap for this?

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

No branches or pull requests