-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
The order of fields in the table and unique constrains is alphabetic instead of the being the same as in class #297
Comments
Order where @ComBatVision ? What method on what class are you calling? |
Order of generated fields in table, in unique constrain of table and in indexes generated from annotations. Should they keep an order from class attributes? |
If I run QueryBuilderTest.testInnerCountOf(), I see the following:
Etc. Notice that the create and inserts don't have sorted fields. What DB are you using? Can you show me a code example that sorts? |
If I delcare any indexes via field annotations they will also in alphabetic oeder like UNIQUE constrain above: UNIQUE ( |
Not according to the javadocs: https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getDeclaredFields--
What JVM are you using? |
I am using Kotlin on Android API 29-34. All of them give me a sorted result. |
Not sure what to do. You can configure your classes using code. See here: https://ormlite.com/docs/config-code |
You might also want to look at the table-config file that was an early Android hack when the annotation parsing was dog slow: https://ormlite.com/docs/table-config |
Lastly, I'm curious why the sorted order is getting in your way? What part of the system doesn't work if the fields are sorted by the JVM? |
Can it be a specific of the Java reflection on Kotlin? Am I right that your code generates the fields in the order returned by reflection, and you do not sort them later? |
May be it is a good idea to add order annotation attribute and sort fields by order if it is specified for Kotlin? |
Yes, ormlite does nothing to the field order. You posted the code above. No |
Should the order field in |
I quickly read some articles, and all of them state that the order of attributes in reflection is not guaranteed and can vary on different Java. So the best way will be to have an order attribute in annotations. Are there any other ideas, except configuriong tables manually? Now, I have performance problems because I found that all my indexes are not in the expected order in production :( |
I think it is enough to be integer, like in ServiceStack OrmLite https://stackoverflow.com/questions/74895170/columns-physical-order-in-ormlite Are there any particular use cases for string ordering? |
Funny example! My "brand" nemesis. I just thought that if you were creating the class and adding fields you would be always running around changing the numbers. Adding a 2nd field in a class with 30 fields would be a pain. That's what I did with my SimpleCSV CsvColumn annotation . Here's another It's interesting that in their example they have just one with with |
I do not know how it behaves in their case. |
Hi. @j256 Any news on this issue? Will you add an order to anotation fro Kotlin? |
Sorry for the delay. I had a couple of other changes queued up that I have to clear. I may back some stuff out. Hope to get out a new release this week. |
Hi, @j256 could you add field ordering, please. It is very important for our project. |
Hi. Is there any updates on this issue? |
Hi, @j256. Do you plan to add this ordering in the nearest future? |
I've actually already added this to main but I'm having problems with a subtle change in H2/MySQL around creating new entities with generated ids that I need a larger amount of time to solve. |
Hi, @j256. |
Hi, can you commnet nay estimates on this issue, please. |
Sorry for the delay. Forking may be easier. I've not had the time recently to resolve other issues that I'm trying to push out in version 7.0 which is up next. |
I have a class with unique and index annotation for fields.
The issue is that order of fields in table, unique constrains and indexes is alphabetic instead of being the same as attibutes in class.
Is it by design?
The text was updated successfully, but these errors were encountered: