Book a Demo

Author Topic: Collection.GetByname is case insensitive  (Read 4228 times)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Collection.GetByname is case insensitive
« on: December 02, 2010, 05:59:43 pm »
The help doesn't say so but experiments I've done seems to suggest that the Collection GetByName method is case insensitive.

Can anyone (preferably Sparx) please confirm this?

If it is case insensitive, what happens if more than one object has the same name?

How are case sensitive languages such as C# handled?  CHours and CHOURS are differnt classes, but GetByName (for class "chours") will only find one - the small amount of experimenting I've done suggests the choice by EA is arbitrary...

Reported,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Collection.GetByname is case insensitive
« Reply #1 on: December 02, 2010, 09:30:03 pm »
Paolo,

I can indeed imagine that GetByName is case insensitive.
If there are multiple elements with the "same" name then I think it will return the "first", but the order doesn't seem to be guaranteed.
That is one of the reasons why I never use GetByName(), and I try to avoid using the EA.Collection alltogether.

Geert

alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: Collection.GetByname is case insensitive
« Reply #2 on: December 03, 2010, 08:36:59 am »
I can confirm that the code is case sensitive.

The case insensitive appears to be a database issue.  
For example, take the following SQL statement
Code: [Select]
SELECT * from table where Name = 'chours'.On an EAP file, it will return the first record that is matched, whereas Postgres will not.

For DBMS's this case sensitivity usually can be toggled to suit your needs.  Remembering that EA API doesn't handle GetByName where the number of elements is greater than 1.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Collection.GetByname is case insensitive
« Reply #3 on: December 03, 2010, 11:34:39 am »
Quote
[size=18]...[/size]
On an EAP file, it will return the first record that is matched, whereas Postgres will not.

For DBMS's this case sensitivity usually can be toggled to suit your needs.  Remembering that EA API doesn't handle GetByName where the number of elements is greater than 1.
Well, in the testing I was doing (admittedly not thorough), the first element matched differed on different runs of the test where there were multiples...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: Collection.GetByname is case insensitive
« Reply #4 on: December 03, 2010, 11:45:56 am »
Sorry, my mistake.

EAP files will return a record whereas postgres would not.

Alistair.
« Last Edit: December 03, 2010, 11:46:09 am by alesliehughes »