## MgDbField

MgDbField — Represents a field in a table or a view in the database

## Synopsis

    struct      MgDbField;
    GObject*    mg_db_field_new                 (MgConf *conf,
                                                 MgServerDataType *type);
    void        mg_db_field_set_length          (MgDbField *field,
                                                 gint length);
    gint        mg_db_field_get_length          (MgDbField *field);
    void        mg_db_field_set_scale           (MgDbField *field,
                                                 gint length);
    gint        mg_db_field_get_scale           (MgDbField *field);
    GSList*     mg_db_field_get_constraints     (MgDbField *field);
    void        mg_db_field_set_data_type       (MgDbField *field,
                                                 MgServerDataType *type);
    void        mg_db_field_set_default_value   (MgDbField *field,
                                                 const GdaValue *value);
    const GdaValue* mg_db_field_get_default_value
                                                (MgDbField *field);
    gboolean    mg_db_field_is_null_allowed     (MgDbField *field);
    gboolean    mg_db_field_is_pkey_part        (MgDbField *field);
    gboolean    mg_db_field_is_pkey_alone       (MgDbField *field);
    gboolean    mg_db_field_is_fkey_part        (MgDbField *field);
    gboolean    mg_db_field_is_fkey_alone       (MgDbField *field);

## Object Hierarchy

      GObject
       +----MgBase
             +----MgDbField

## Implemented Interfaces

MgDbField implements MgXmlStorage, MgRenderer and MgField.

## Properties

      "db-table"             gpointer             : Read / Write

## Signal Prototypes

    "templ-signal"
                void        user_function      (MgDbField *mgdbfield,
                                                gpointer user_data);

## Description

It implements the following interfaces: MgField, MgXmlStorage and MgRenderer.

## Details

### struct MgDbField

    struct MgDbField;

### mg_db_field_new ()

    GObject*    mg_db_field_new                 (MgConf *conf,
                                                 MgServerDataType *type);

Creates a new MgDbField object

`conf` : | a MgConf object
`type` : | a MgServerDataType object (the field's type)
Returns : | the new object

### mg_db_field_set_length ()

    void        mg_db_field_set_length          (MgDbField *field,
                                                 gint length);

`field` : |
`length` : |

### mg_db_field_get_length ()

    gint        mg_db_field_get_length          (MgDbField *field);

Get the length of a field.

`field` : | a MgDbField object
Returns : | the size of the corresponding data type has a fixed size, or -1

### mg_db_field_set_scale ()

    void        mg_db_field_set_scale           (MgDbField *field,
                                                 gint length);

`field` : |
`length` : |

### mg_db_field_get_scale ()

    gint        mg_db_field_get_scale           (MgDbField *field);

Get the scale of a field.

`field` : | a MgDbField object
Returns : | the size of the corresponding data type has a fixed size, or -1

### mg_db_field_get_constraints ()

    GSList*     mg_db_field_get_constraints     (MgDbField *field);

Get all the constraints which impact the given field. Constraints are of several type: NOT NULL, primary key, foreign key, check constrains

`field` : | a MgDbField object
Returns : | a new list of MgDbConstraint objects

### mg_db_field_set_data_type ()

    void        mg_db_field_set_data_type       (MgDbField *field,
                                                 MgServerDataType *type);

Sets the data type of the field

`field` : | a MgDbField object
`type` : | a MgServerDataType object

### mg_db_field_set_default_value ()

    void        mg_db_field_set_default_value   (MgDbField *field,
                                                 const GdaValue *value);

Sets (or replace) the default value for the field. WARNING: the default value's data type can be different from the field's data type (this is the case for example if the default value is a function like Postgres's default value for the SERIAL data type).

`field` : | a MgDbField object
`value` : | a GdaValue value or NULL

### mg_db_field_get_default_value ()

    const GdaValue* mg_db_field_get_default_value
                                                (MgDbField *field);

Get the default value for the field if ne exists

`field` : | a MgDbField object
Returns : | the default value

### mg_db_field_is_null_allowed ()

    gboolean    mg_db_field_is_null_allowed     (MgDbField *field);

`field` : |
Returns : |

### mg_db_field_is_pkey_part ()

    gboolean    mg_db_field_is_pkey_part        (MgDbField *field);

`field` : |
Returns : |

### mg_db_field_is_pkey_alone ()

    gboolean    mg_db_field_is_pkey_alone       (MgDbField *field);

`field` : |
Returns : |

### mg_db_field_is_fkey_part ()

    gboolean    mg_db_field_is_fkey_part        (MgDbField *field);

`field` : |
Returns : |

### mg_db_field_is_fkey_alone ()

    gboolean    mg_db_field_is_fkey_alone       (MgDbField *field);

`field` : |
Returns : |

## Properties

"`db-table`" (gpointer : Read / Write) |

## Signals

### The "templ-signal" signal

    void        user_function                  (MgDbField *mgdbfield,
                                                gpointer user_data);

`mgdbfield` : | the object which received the signal.
`user_data` : | user data set when the signal handler was connected.