[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What happened to gb.db2?


In gb.db, resultFields is an Array[] of resultFields objects. You can
obtain the name of a field with MyResult.Fields[n].Name.
In gb.db2 resultFields is a collection with the Field.Name as key and the
resultfield object as value. You can obtain the name of a field with
MyResult.fields["name"], for example.

I have a lot of controls and routines who work with resultfields.names and
this is a little annoying.

What I've done is a little function who discriminate what version is
actually running:

Public Function Fieldnames(r As Result) As String[]

Dim $cFields As New String[]
  Dim n As Integer

  If Object.Class(r).Component.Name = "gb.db2" Then
    Dim skey As ResultField
    For Each skey In r.Fields
      $cFields.Add(skey.Name)
    Next
  Else
    For n = 0 To r.Fields.Count - 1
      $cFields.Add(r.Fields[n].Name)
    Next
  Endif
  Return $cFields

End

and implemented it on my projects. I didn't know if it was a bug, so I
didn't report it.

Another issue that bothered me is that Gambas seems to ignore the name set
in the SQL query with the AS 'NAME' clause and returns the `Table.Field`
pair as the name. This is fine if no name is explicitly set, but if an AS
clause is set, this name should be respected for the field name....
... BUT this behavior also existed in the previous version, so I don't
think it's a bug in gb.db2 either. Maybe something to add to the wish
list...

Best Regards

El dom, 27 abr 2025 a las 15:45, Christof Thalhofer (<chrisml@xxxxxxxxxxx>)
escribió:

> Am 27.04.25 um 10:54 schrieb Jorge Carrión:
>
> > Since gb.db2 arrived, I've been updating a ton of projects due to the
> > different way it handles the .Fields collection and anticipating that
> > sooner or later the obsolete gb.db component would disappear.
>
> What??? Is gb.db2 not compatible with gb.db? Did you write a bug report?
>
> https://lists.gambas-basic.org/archive/user/2024-06/0000100.html
>
> Alles Gute
>
> Christof Thalhofer
>
> --
> [x] nail here for new monitor
>
>
>

Follow-Ups:
Re: What happened to gb.db2?Lee <t.lee.davidson@xxxxxxxxx>
Re: What happened to gb.db2?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: What happened to gb.db2?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
Re: What happened to gb.db2?Benoît Minisini <benoit.minisini@xxxxxxxxxxxxxxxx>
References:
What happened to gb.db2?Jorge Carrión <shordi@xxxxxxxxx>
Re: What happened to gb.db2?Christof Thalhofer <chrisml@xxxxxxxxxxx>