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

Auto trim varchar vs trim char in 0.9.8 #167

Open
McFris opened this issue Mar 25, 2024 · 4 comments
Open

Auto trim varchar vs trim char in 0.9.8 #167

McFris opened this issue Mar 25, 2024 · 4 comments

Comments

@McFris
Copy link

McFris commented Mar 25, 2024

create procedure TEST_TRIM
returns (
    CH char(4),
    VARCH varchar(4))
as
begin
   CH = 'F   ';
   VARCH = 'F   ';
   suspend;
end

require github.com/nakagami/firebirdsql v0.9.8

conn.QueryRow(`select ch, trim(ch) trimch, varch, trim(varch) trimvarch from test_trim`).Scan(&a.Ch, &a.TrimCh, &a.VarCh, &a.TrimVarCh)

fmt.Printf("Char is: '%s', hex: %v\n", a.Ch, []byte(a.Ch))
fmt.Printf("Trim char is: '%s', hex: %v\n", a.TrimCh, []byte(a.TrimCh))

fmt.Printf("Varchar is: '%s', hex: %v\n", a.VarCh, []byte(a.VarCh))
fmt.Printf("Trim varchar is: '%s', hex: %v\n", a.TrimVarCh, []byte(a.TrimVarCh))

Result:
Char is: 'F', hex: [70]
Trim char is: 'F', hex: [70]
Varchar is: 'F ', hex: [70 32 32 32] <<<<<<<<<<<<<
Trim varchar is: 'F', hex: [70]

@nakagami
Copy link
Owner

CHAR is trimmed
VARCHAR is not trimmed
These behaviors are as expected.

@McFris
Copy link
Author

McFris commented Mar 25, 2024

Is there possibility to make forced trimming similar for all text fields, at least as an option?
Similar to FIBPlus for Delphi?
изображение

@palevi67
Copy link

palevi67 commented Jun 4, 2024

I don't know if there is any agreement on whether char fields should be trimmed or not, but I can say that the postgresql drivers don't do it.

@McFris
Copy link
Author

McFris commented Jun 4, 2024

I don't know if there is any agreement on whether char fields should be trimmed or not, but I can say that the postgresql drivers don't do it.

And that's why we always have to write such a SQL query:
select trim(DATWEB) datweb, trim(CLIENT) client, trim(TIP) tip, trim(PROJECT) project from select_procedure

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

No branches or pull requests

3 participants