Skip to content

Remove default field value from result field metadata to match mysql C client #2

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ An OCaml wrapper for the MySQL C API (v8.0). This project is a fork of
[ocaml-mysql](https://github.com/ygrek/ocaml-mysql) with updates to handle
MySQL 8.

You probably need the *fix-build* branch.

# Install
You can install the library with:

Expand Down
4 changes: 2 additions & 2 deletions lib/mysql8.ml
Original file line number Diff line number Diff line change
Expand Up @@ -721,8 +721,8 @@ type field =
; (* Name of the field *)
table : string option
; (* Table name, or None if a constructed field *)
def : string option
; (* Default value of the field *)
(* def : string option
; *)(* Default value of the field *)
ty : dbty
; max_length : int
; (* Maximum width of field for the result set *)
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql8.mli
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ type dbty =
type field =
{ name : string (** Name of the field *)
; table : string option (** Table name, or None if a constructed field *)
; def : string option (** Default value of the field *)
(* ; def : string option ( * * Default value of the field *)
; ty : dbty (** The type of data stored in the field *)
; max_length : int (** Maximum width of field for the result set *)
; flags : int (** Flags set *)
Expand Down
15 changes: 8 additions & 7 deletions lib/mysql8_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,19 +839,20 @@ value make_field(MYSQL_FIELD *f)
else
table = Val_none;

/*
if (f->def)
def = val_str_option(f->def, strlen(f->def));
else
def = Val_none;

data = caml_alloc_small(7, 0);
*/
data = caml_alloc_small(6, 0);
Field(data, 0) = name;
Field(data, 1) = table;
Field(data, 2) = def;
Field(data, 3) = type2dbty(f->type);
Field(data, 4) = Val_long(f->max_length);
Field(data, 5) = Val_long(f->flags);
Field(data, 6) = Val_long(f->decimals);
// Field(data, 2) = def;
Field(data, 2) = type2dbty(f->type);
Field(data, 3) = Val_long(f->max_length);
Field(data, 4) = Val_long(f->flags);
Field(data, 5) = Val_long(f->decimals);

CAMLreturn(data);
}
Expand Down