/* update_builder.c generated by valac 0.56.19, the Vala compiler
 * generated from update_builder.vala, do not modify */

#include "qlite.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <sqlite3.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD (qlite_statement_builder_abstract_field_get_type ())
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractField))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_ABSTRACT_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD))
#define QLITE_STATEMENT_BUILDER_ABSTRACT_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_ABSTRACT_FIELD, QliteStatementBuilderAbstractFieldClass))

typedef struct _QliteStatementBuilderAbstractField QliteStatementBuilderAbstractField;
typedef struct _QliteStatementBuilderAbstractFieldClass QliteStatementBuilderAbstractFieldClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _qlite_table_unref0(var) ((var == NULL) ? NULL : (var = (qlite_table_unref (var), NULL)))

#define QLITE_STATEMENT_BUILDER_TYPE_FIELD (qlite_statement_builder_field_get_type ())
#define QLITE_STATEMENT_BUILDER_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderField))
#define QLITE_STATEMENT_BUILDER_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_FIELD))
#define QLITE_STATEMENT_BUILDER_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_FIELD, QliteStatementBuilderFieldClass))

typedef struct _QliteStatementBuilderField QliteStatementBuilderField;
typedef struct _QliteStatementBuilderFieldClass QliteStatementBuilderFieldClass;

#define QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD (qlite_statement_builder_null_field_get_type ())
#define QLITE_STATEMENT_BUILDER_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullField))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_NULL_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD))
#define QLITE_STATEMENT_BUILDER_NULL_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_NULL_FIELD, QliteStatementBuilderNullFieldClass))

typedef struct _QliteStatementBuilderNullField QliteStatementBuilderNullField;
typedef struct _QliteStatementBuilderNullFieldClass QliteStatementBuilderNullFieldClass;

#define QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD (qlite_statement_builder_string_field_get_type ())
#define QLITE_STATEMENT_BUILDER_STRING_FIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringField))
#define QLITE_STATEMENT_BUILDER_STRING_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringFieldClass))
#define QLITE_STATEMENT_BUILDER_IS_STRING_FIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD))
#define QLITE_STATEMENT_BUILDER_IS_STRING_FIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD))
#define QLITE_STATEMENT_BUILDER_STRING_FIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), QLITE_STATEMENT_BUILDER_TYPE_STRING_FIELD, QliteStatementBuilderStringFieldClass))

typedef struct _QliteStatementBuilderStringField QliteStatementBuilderStringField;
typedef struct _QliteStatementBuilderStringFieldClass QliteStatementBuilderStringFieldClass;
typedef struct _QliteStatementBuilderAbstractFieldPrivate QliteStatementBuilderAbstractFieldPrivate;
#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))

struct _QliteUpdateBuilderPrivate {
	gchar* or_val;
	QliteTable* table;
	gchar* table_name;
	QliteStatementBuilderAbstractField** fields;
	gint fields_length1;
	gint _fields_size_;
	gchar* selection;
	QliteStatementBuilderAbstractField** selection_args;
	gint selection_args_length1;
	gint _selection_args_size_;
};

struct _QliteStatementBuilderAbstractField {
	GTypeInstance parent_instance;
	volatile int ref_count;
	QliteStatementBuilderAbstractFieldPrivate * priv;
	gpointer value;
	QliteColumn* column;
};

struct _QliteStatementBuilderAbstractFieldClass {
	GTypeClass parent_class;
	void (*finalize) (QliteStatementBuilderAbstractField *self);
	void (*bind) (QliteStatementBuilderAbstractField* self, sqlite3_stmt* stmt, gint index);
};

static gint QliteUpdateBuilder_private_offset;
static gpointer qlite_update_builder_parent_class = NULL;

VALA_EXTERN gpointer qlite_statement_builder_abstract_field_ref (gpointer instance);
VALA_EXTERN void qlite_statement_builder_abstract_field_unref (gpointer instance);
VALA_EXTERN GParamSpec* qlite_statement_builder_param_spec_abstract_field (const gchar* name,
                                                               const gchar* nick,
                                                               const gchar* blurb,
                                                               GType object_type,
                                                               GParamFlags flags);
VALA_EXTERN void qlite_statement_builder_value_set_abstract_field (GValue* value,
                                                       gpointer v_object);
VALA_EXTERN void qlite_statement_builder_value_take_abstract_field (GValue* value,
                                                        gpointer v_object);
VALA_EXTERN gpointer qlite_statement_builder_value_get_abstract_field (const GValue* value);
VALA_EXTERN GType qlite_statement_builder_abstract_field_get_type (void) G_GNUC_CONST ;
VALA_EXTERN sqlite3_stmt* qlite_statement_builder_prepare (QliteStatementBuilder* self);
VALA_EXTERN QliteUpdateBuilder* qlite_update_builder_new (QliteDatabase* db,
                                              QliteTable* table);
VALA_EXTERN QliteUpdateBuilder* qlite_update_builder_construct (GType object_type,
                                                    QliteDatabase* db,
                                                    QliteTable* table);
VALA_EXTERN QliteStatementBuilder* qlite_statement_builder_construct (GType object_type,
                                                          QliteDatabase* db);
VALA_EXTERN QliteUpdateBuilder* qlite_update_builder_new_for_name (QliteDatabase* db,
                                                       const gchar* table);
VALA_EXTERN QliteUpdateBuilder* qlite_update_builder_construct_for_name (GType object_type,
                                                             QliteDatabase* db,
                                                             const gchar* table);
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_new (GType t_type,
                                                               GBoxedCopyFunc t_dup_func,
                                                               GDestroyNotify t_destroy_func,
                                                               QliteColumn* column,
                                                               gconstpointer value);
VALA_EXTERN QliteStatementBuilderField* qlite_statement_builder_field_construct (GType object_type,
                                                                     GType t_type,
                                                                     GBoxedCopyFunc t_dup_func,
                                                                     GDestroyNotify t_destroy_func,
                                                                     QliteColumn* column,
                                                                     gconstpointer value);
VALA_EXTERN GType qlite_statement_builder_field_get_type (void) G_GNUC_CONST ;
static void _vala_array_add12 (QliteStatementBuilderAbstractField** * array,
                        gint* length,
                        gint* size,
                        QliteStatementBuilderAbstractField* value);
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_new (GType t_type,
                                                                        GBoxedCopyFunc t_dup_func,
                                                                        GDestroyNotify t_destroy_func,
                                                                        QliteColumn* column);
VALA_EXTERN QliteStatementBuilderNullField* qlite_statement_builder_null_field_construct (GType object_type,
                                                                              GType t_type,
                                                                              GBoxedCopyFunc t_dup_func,
                                                                              GDestroyNotify t_destroy_func,
                                                                              QliteColumn* column);
VALA_EXTERN GType qlite_statement_builder_null_field_get_type (void) G_GNUC_CONST ;
static void _vala_array_add13 (QliteStatementBuilderAbstractField** * array,
                        gint* length,
                        gint* size,
                        QliteStatementBuilderAbstractField* value);
VALA_EXTERN QliteStatementBuilderStringField* qlite_statement_builder_string_field_new (const gchar* value);
VALA_EXTERN QliteStatementBuilderStringField* qlite_statement_builder_string_field_construct (GType object_type,
                                                                                  const gchar* value);
VALA_EXTERN GType qlite_statement_builder_string_field_get_type (void) G_GNUC_CONST ;
static void _vala_array_add14 (QliteStatementBuilderAbstractField** * array,
                        gint* length,
                        gint* size,
                        QliteStatementBuilderAbstractField* value);
static void _vala_array_add15 (QliteStatementBuilderAbstractField** * array,
                        gint* length,
                        gint* size,
                        QliteStatementBuilderAbstractField* value);
static sqlite3_stmt* qlite_update_builder_real_prepare (QliteStatementBuilder* base);
VALA_EXTERN sqlite3_stmt* qlite_database_prepare (QliteDatabase* self,
                                      const gchar* sql);
VALA_EXTERN void qlite_statement_builder_abstract_field_bind (QliteStatementBuilderAbstractField* self,
                                                  sqlite3_stmt* stmt,
                                                  gint index);
VALA_EXTERN gint qlite_database_errcode (QliteDatabase* self);
VALA_EXTERN gchar* qlite_database_errmsg (QliteDatabase* self);
static void qlite_update_builder_finalize (QliteStatementBuilder * obj);
static GType qlite_update_builder_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
qlite_update_builder_get_instance_private (QliteUpdateBuilder* self)
{
	return G_STRUCT_MEMBER_P (self, QliteUpdateBuilder_private_offset);
}

static gpointer
_qlite_table_ref0 (gpointer self)
{
	return self ? qlite_table_ref (self) : NULL;
}

QliteUpdateBuilder*
qlite_update_builder_construct (GType object_type,
                                QliteDatabase* db,
                                QliteTable* table)
{
	QliteUpdateBuilder* self = NULL;
	QliteTable* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_val_if_fail (db != NULL, NULL);
	g_return_val_if_fail (table != NULL, NULL);
	self = (QliteUpdateBuilder*) qlite_statement_builder_construct (object_type, db);
	_tmp0_ = _qlite_table_ref0 (table);
	_qlite_table_unref0 (self->priv->table);
	self->priv->table = _tmp0_;
	_tmp1_ = qlite_table_get_name (table);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (self->priv->table_name);
	self->priv->table_name = _tmp3_;
	return self;
}

QliteUpdateBuilder*
qlite_update_builder_new (QliteDatabase* db,
                          QliteTable* table)
{
	return qlite_update_builder_construct (QLITE_TYPE_UPDATE_BUILDER, db, table);
}

QliteUpdateBuilder*
qlite_update_builder_construct_for_name (GType object_type,
                                         QliteDatabase* db,
                                         const gchar* table)
{
	QliteUpdateBuilder* self = NULL;
	gchar* _tmp0_;
	g_return_val_if_fail (db != NULL, NULL);
	g_return_val_if_fail (table != NULL, NULL);
	self = (QliteUpdateBuilder*) qlite_statement_builder_construct (object_type, db);
	_tmp0_ = g_strdup (table);
	_g_free0 (self->priv->table_name);
	self->priv->table_name = _tmp0_;
	return self;
}

QliteUpdateBuilder*
qlite_update_builder_new_for_name (QliteDatabase* db,
                                   const gchar* table)
{
	return qlite_update_builder_construct_for_name (QLITE_TYPE_UPDATE_BUILDER, db, table);
}

static gpointer
_qlite_statement_builder_ref0 (gpointer self)
{
	return self ? qlite_statement_builder_ref (self) : NULL;
}

QliteUpdateBuilder*
qlite_update_builder_or (QliteUpdateBuilder* self,
                         const gchar* or)
{
	gchar* _tmp0_;
	QliteUpdateBuilder* _tmp1_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (or != NULL, NULL);
	_tmp0_ = g_strdup (or);
	_g_free0 (self->priv->or_val);
	self->priv->or_val = _tmp0_;
	_tmp1_ = _qlite_statement_builder_ref0 (self);
	result = _tmp1_;
	return result;
}

static void
_vala_array_add12 (QliteStatementBuilderAbstractField** * array,
                   gint* length,
                   gint* size,
                   QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

QliteUpdateBuilder*
qlite_update_builder_set (QliteUpdateBuilder* self,
                          GType t_type,
                          GBoxedCopyFunc t_dup_func,
                          GDestroyNotify t_destroy_func,
                          QliteColumn* column,
                          gconstpointer value)
{
	QliteStatementBuilderField* _tmp0_;
	QliteUpdateBuilder* _tmp1_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = qlite_statement_builder_field_new (t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, column, value);
	_vala_array_add12 (&self->priv->fields, &self->priv->fields_length1, &self->priv->_fields_size_, (QliteStatementBuilderAbstractField*) _tmp0_);
	_tmp1_ = _qlite_statement_builder_ref0 (self);
	result = _tmp1_;
	return result;
}

static void
_vala_array_add13 (QliteStatementBuilderAbstractField** * array,
                   gint* length,
                   gint* size,
                   QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

QliteUpdateBuilder*
qlite_update_builder_set_null (QliteUpdateBuilder* self,
                               GType t_type,
                               GBoxedCopyFunc t_dup_func,
                               GDestroyNotify t_destroy_func,
                               QliteColumn* column)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	QliteStatementBuilderNullField* _tmp4_;
	QliteUpdateBuilder* _tmp5_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = qlite_column_get_not_null (column);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = qlite_column_get_name (column);
		_tmp3_ = _tmp2_;
		g_error ("update_builder.vala:43: Can't set non-null column %s to null", _tmp3_);
	}
	_tmp4_ = qlite_statement_builder_null_field_new (t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, column);
	_vala_array_add13 (&self->priv->fields, &self->priv->fields_length1, &self->priv->_fields_size_, (QliteStatementBuilderAbstractField*) _tmp4_);
	_tmp5_ = _qlite_statement_builder_ref0 (self);
	result = _tmp5_;
	return result;
}

static void
_vala_array_add14 (QliteStatementBuilderAbstractField** * array,
                   gint* length,
                   gint* size,
                   QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

QliteUpdateBuilder*
qlite_update_builder_where (QliteUpdateBuilder* self,
                            const gchar* selection,
                            gchar** selection_args,
                            gint selection_args_length1)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	QliteUpdateBuilder* _tmp5_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (selection != NULL, NULL);
	_tmp0_ = self->priv->selection;
	if (g_strcmp0 (_tmp0_, "1") != 0) {
		g_error ("update_builder.vala:49: selection was already done, but where() was ca" \
"lled.");
	}
	_tmp1_ = g_strdup (selection);
	_g_free0 (self->priv->selection);
	self->priv->selection = _tmp1_;
	{
		gchar** arg_collection = NULL;
		gint arg_collection_length1 = 0;
		gint _arg_collection_size_ = 0;
		gint arg_it = 0;
		arg_collection = selection_args;
		arg_collection_length1 = selection_args_length1;
		for (arg_it = 0; arg_it < arg_collection_length1; arg_it = arg_it + 1) {
			gchar* _tmp2_;
			gchar* arg = NULL;
			_tmp2_ = g_strdup (arg_collection[arg_it]);
			arg = _tmp2_;
			{
				const gchar* _tmp3_;
				QliteStatementBuilderStringField* _tmp4_;
				_tmp3_ = arg;
				_tmp4_ = qlite_statement_builder_string_field_new (_tmp3_);
				_vala_array_add14 (&self->priv->selection_args, &self->priv->selection_args_length1, &self->priv->_selection_args_size_, (QliteStatementBuilderAbstractField*) _tmp4_);
				_g_free0 (arg);
			}
		}
	}
	_tmp5_ = _qlite_statement_builder_ref0 (self);
	result = _tmp5_;
	return result;
}

static void
_vala_array_add15 (QliteStatementBuilderAbstractField** * array,
                   gint* length,
                   gint* size,
                   QliteStatementBuilderAbstractField* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (QliteStatementBuilderAbstractField*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

QliteUpdateBuilder*
qlite_update_builder_with (QliteUpdateBuilder* self,
                           GType t_type,
                           GBoxedCopyFunc t_dup_func,
                           GDestroyNotify t_destroy_func,
                           QliteColumn* column,
                           const gchar* comp,
                           gconstpointer value)
{
	QliteStatementBuilderField* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	QliteUpdateBuilder* _tmp8_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	g_return_val_if_fail (comp != NULL, NULL);
	_tmp0_ = qlite_statement_builder_field_new (t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, column, value);
	_vala_array_add15 (&self->priv->selection_args, &self->priv->selection_args_length1, &self->priv->_selection_args_size_, (QliteStatementBuilderAbstractField*) _tmp0_);
	_tmp1_ = self->priv->selection;
	_tmp2_ = string_to_string (_tmp1_);
	_tmp3_ = qlite_column_get_name (column);
	_tmp4_ = _tmp3_;
	_tmp5_ = string_to_string (_tmp4_);
	_tmp6_ = string_to_string (comp);
	_tmp7_ = g_strconcat ("(", _tmp2_, ") AND ", _tmp5_, " ", _tmp6_, " ?", NULL);
	_g_free0 (self->priv->selection);
	self->priv->selection = _tmp7_;
	_tmp8_ = _qlite_statement_builder_ref0 (self);
	result = _tmp8_;
	return result;
}

QliteUpdateBuilder*
qlite_update_builder_with_null (QliteUpdateBuilder* self,
                                GType t_type,
                                GBoxedCopyFunc t_dup_func,
                                GDestroyNotify t_destroy_func,
                                QliteColumn* column)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	QliteUpdateBuilder* _tmp6_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = self->priv->selection;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = qlite_column_get_name (column);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_to_string (_tmp3_);
	_tmp5_ = g_strconcat ("(", _tmp1_, ") AND ", _tmp4_, " ISNULL", NULL);
	_g_free0 (self->priv->selection);
	self->priv->selection = _tmp5_;
	_tmp6_ = _qlite_statement_builder_ref0 (self);
	result = _tmp6_;
	return result;
}

QliteUpdateBuilder*
qlite_update_builder_without_null (QliteUpdateBuilder* self,
                                   GType t_type,
                                   GBoxedCopyFunc t_dup_func,
                                   GDestroyNotify t_destroy_func,
                                   QliteColumn* column)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	QliteUpdateBuilder* _tmp6_;
	QliteUpdateBuilder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	_tmp0_ = self->priv->selection;
	_tmp1_ = string_to_string (_tmp0_);
	_tmp2_ = qlite_column_get_name (column);
	_tmp3_ = _tmp2_;
	_tmp4_ = string_to_string (_tmp3_);
	_tmp5_ = g_strconcat ("(", _tmp1_, ") AND ", _tmp4_, " NOT NULL", NULL);
	_g_free0 (self->priv->selection);
	self->priv->selection = _tmp5_;
	_tmp6_ = _qlite_statement_builder_ref0 (self);
	result = _tmp6_;
	return result;
}

static sqlite3_stmt*
qlite_update_builder_real_prepare (QliteStatementBuilder* base)
{
	QliteUpdateBuilder * self;
	gchar* sql = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	sqlite3_stmt* stmt = NULL;
	QliteDatabase* _tmp35_;
	const gchar* _tmp36_;
	sqlite3_stmt* _tmp37_;
	sqlite3_stmt* result;
	self = (QliteUpdateBuilder*) base;
	_tmp0_ = g_strdup ("UPDATE");
	sql = _tmp0_;
	_tmp1_ = self->priv->or_val;
	if (_tmp1_ != NULL) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp2_ = sql;
		_tmp3_ = self->priv->or_val;
		_tmp4_ = string_to_string ((const gchar*) _tmp3_);
		_tmp5_ = g_strconcat (" OR ", _tmp4_, NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat (_tmp2_, _tmp6_, NULL);
		_g_free0 (sql);
		sql = _tmp7_;
		_g_free0 (_tmp6_);
	}
	_tmp8_ = sql;
	_tmp9_ = self->priv->table_name;
	_tmp10_ = string_to_string (_tmp9_);
	_tmp11_ = g_strconcat (" ", _tmp10_, " SET ", NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp8_, _tmp12_, NULL);
	_g_free0 (sql);
	sql = _tmp13_;
	_g_free0 (_tmp12_);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp14_ = FALSE;
			_tmp14_ = TRUE;
			while (TRUE) {
				QliteStatementBuilderAbstractField** _tmp16_;
				gint _tmp16__length1;
				const gchar* _tmp19_;
				QliteStatementBuilderAbstractField** _tmp20_;
				gint _tmp20__length1;
				QliteStatementBuilderAbstractField* _tmp21_;
				QliteColumn* _tmp22_;
				const gchar* _tmp23_;
				const gchar* _tmp24_;
				const gchar* _tmp25_;
				gchar* _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				if (!_tmp14_) {
					gint _tmp15_;
					_tmp15_ = i;
					i = _tmp15_ + 1;
				}
				_tmp14_ = FALSE;
				_tmp16_ = self->priv->fields;
				_tmp16__length1 = self->priv->fields_length1;
				if (!(i < _tmp16__length1)) {
					break;
				}
				if (i != 0) {
					const gchar* _tmp17_;
					gchar* _tmp18_;
					_tmp17_ = sql;
					_tmp18_ = g_strconcat (_tmp17_, ", ", NULL);
					_g_free0 (sql);
					sql = _tmp18_;
				}
				_tmp19_ = sql;
				_tmp20_ = self->priv->fields;
				_tmp20__length1 = self->priv->fields_length1;
				_tmp21_ = _tmp20_[i];
				_tmp22_ = _tmp21_->column;
				_tmp23_ = qlite_column_get_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, QLITE_TYPE_COLUMN, QliteColumn));
				_tmp24_ = _tmp23_;
				_tmp25_ = string_to_string (_tmp24_);
				_tmp26_ = g_strconcat (_tmp25_, " = ?", NULL);
				_tmp27_ = _tmp26_;
				_tmp28_ = g_strconcat (_tmp19_, _tmp27_, NULL);
				_g_free0 (sql);
				sql = _tmp28_;
				_g_free0 (_tmp27_);
			}
		}
	}
	_tmp29_ = sql;
	_tmp30_ = self->priv->selection;
	_tmp31_ = string_to_string (_tmp30_);
	_tmp32_ = g_strconcat (" WHERE ", _tmp31_, NULL);
	_tmp33_ = _tmp32_;
	_tmp34_ = g_strconcat (_tmp29_, _tmp33_, NULL);
	_g_free0 (sql);
	sql = _tmp34_;
	_g_free0 (_tmp33_);
	_tmp35_ = ((QliteStatementBuilder*) self)->db;
	_tmp36_ = sql;
	_tmp37_ = qlite_database_prepare (_tmp35_, _tmp36_);
	stmt = _tmp37_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp38_ = FALSE;
			_tmp38_ = TRUE;
			while (TRUE) {
				QliteStatementBuilderAbstractField** _tmp40_;
				gint _tmp40__length1;
				QliteStatementBuilderAbstractField** _tmp41_;
				gint _tmp41__length1;
				QliteStatementBuilderAbstractField* _tmp42_;
				sqlite3_stmt* _tmp43_;
				if (!_tmp38_) {
					gint _tmp39_;
					_tmp39_ = i;
					i = _tmp39_ + 1;
				}
				_tmp38_ = FALSE;
				_tmp40_ = self->priv->fields;
				_tmp40__length1 = self->priv->fields_length1;
				if (!(i < _tmp40__length1)) {
					break;
				}
				_tmp41_ = self->priv->fields;
				_tmp41__length1 = self->priv->fields_length1;
				_tmp42_ = _tmp41_[i];
				_tmp43_ = stmt;
				qlite_statement_builder_abstract_field_bind (_tmp42_, _tmp43_, i + 1);
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp44_ = FALSE;
			_tmp44_ = TRUE;
			while (TRUE) {
				QliteStatementBuilderAbstractField** _tmp46_;
				gint _tmp46__length1;
				QliteStatementBuilderAbstractField** _tmp47_;
				gint _tmp47__length1;
				QliteStatementBuilderAbstractField* _tmp48_;
				sqlite3_stmt* _tmp49_;
				QliteStatementBuilderAbstractField** _tmp50_;
				gint _tmp50__length1;
				if (!_tmp44_) {
					gint _tmp45_;
					_tmp45_ = i;
					i = _tmp45_ + 1;
				}
				_tmp44_ = FALSE;
				_tmp46_ = self->priv->selection_args;
				_tmp46__length1 = self->priv->selection_args_length1;
				if (!(i < _tmp46__length1)) {
					break;
				}
				_tmp47_ = self->priv->selection_args;
				_tmp47__length1 = self->priv->selection_args_length1;
				_tmp48_ = _tmp47_[i];
				_tmp49_ = stmt;
				_tmp50_ = self->priv->fields;
				_tmp50__length1 = self->priv->fields_length1;
				qlite_statement_builder_abstract_field_bind (_tmp48_, _tmp49_, (i + _tmp50__length1) + 1);
			}
		}
	}
	result = stmt;
	_g_free0 (sql);
	return result;
}

void
qlite_update_builder_perform (QliteUpdateBuilder* self)
{
	QliteStatementBuilderAbstractField** _tmp0_;
	gint _tmp0__length1;
	sqlite3_stmt* _tmp1_;
	sqlite3_stmt* _tmp2_;
	gboolean _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->fields;
	_tmp0__length1 = self->priv->fields_length1;
	if (_tmp0__length1 == 0) {
		return;
	}
	_tmp1_ = qlite_statement_builder_prepare ((QliteStatementBuilder*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = sqlite3_step (_tmp2_) != SQLITE_DONE;
	_sqlite3_finalize0 (_tmp2_);
	if (_tmp3_) {
		QliteDatabase* _tmp4_;
		QliteDatabase* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = ((QliteStatementBuilder*) self)->db;
		_tmp5_ = ((QliteStatementBuilder*) self)->db;
		_tmp6_ = qlite_database_errmsg (_tmp5_);
		_tmp7_ = _tmp6_;
		g_critical ("update_builder.vala:97: SQLite error: %d - %s", qlite_database_errcode (_tmp4_), _tmp7_);
		_g_free0 (_tmp7_);
	}
}

static void
qlite_update_builder_class_init (QliteUpdateBuilderClass * klass,
                                 gpointer klass_data)
{
	qlite_update_builder_parent_class = g_type_class_peek_parent (klass);
	((QliteStatementBuilderClass *) klass)->finalize = qlite_update_builder_finalize;
	g_type_class_adjust_private_offset (klass, &QliteUpdateBuilder_private_offset);
	((QliteStatementBuilderClass *) klass)->prepare = (sqlite3_stmt* (*) (QliteStatementBuilder*)) qlite_update_builder_real_prepare;
}

static void
qlite_update_builder_instance_init (QliteUpdateBuilder * self,
                                    gpointer klass)
{
	QliteStatementBuilderAbstractField** _tmp0_;
	gchar* _tmp1_;
	QliteStatementBuilderAbstractField** _tmp2_;
	self->priv = qlite_update_builder_get_instance_private (self);
	_tmp0_ = g_new0 (QliteStatementBuilderAbstractField*, 0 + 1);
	self->priv->fields = _tmp0_;
	self->priv->fields_length1 = 0;
	self->priv->_fields_size_ = self->priv->fields_length1;
	_tmp1_ = g_strdup ("1");
	self->priv->selection = _tmp1_;
	_tmp2_ = g_new0 (QliteStatementBuilderAbstractField*, 0 + 1);
	self->priv->selection_args = _tmp2_;
	self->priv->selection_args_length1 = 0;
	self->priv->_selection_args_size_ = self->priv->selection_args_length1;
}

static void
qlite_update_builder_finalize (QliteStatementBuilder * obj)
{
	QliteUpdateBuilder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, QLITE_TYPE_UPDATE_BUILDER, QliteUpdateBuilder);
	_g_free0 (self->priv->or_val);
	_qlite_table_unref0 (self->priv->table);
	_g_free0 (self->priv->table_name);
	self->priv->fields = (_vala_array_free (self->priv->fields, self->priv->fields_length1, (GDestroyNotify) qlite_statement_builder_abstract_field_unref), NULL);
	_g_free0 (self->priv->selection);
	self->priv->selection_args = (_vala_array_free (self->priv->selection_args, self->priv->selection_args_length1, (GDestroyNotify) qlite_statement_builder_abstract_field_unref), NULL);
	QLITE_STATEMENT_BUILDER_CLASS (qlite_update_builder_parent_class)->finalize (obj);
}

static GType
qlite_update_builder_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (QliteUpdateBuilderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) qlite_update_builder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (QliteUpdateBuilder), 0, (GInstanceInitFunc) qlite_update_builder_instance_init, NULL };
	GType qlite_update_builder_type_id;
	qlite_update_builder_type_id = g_type_register_static (QLITE_TYPE_STATEMENT_BUILDER, "QliteUpdateBuilder", &g_define_type_info, 0);
	QliteUpdateBuilder_private_offset = g_type_add_instance_private (qlite_update_builder_type_id, sizeof (QliteUpdateBuilderPrivate));
	return qlite_update_builder_type_id;
}

GType
qlite_update_builder_get_type (void)
{
	static volatile gsize qlite_update_builder_type_id__once = 0;
	if (g_once_init_enter (&qlite_update_builder_type_id__once)) {
		GType qlite_update_builder_type_id;
		qlite_update_builder_type_id = qlite_update_builder_get_type_once ();
		g_once_init_leave (&qlite_update_builder_type_id__once, qlite_update_builder_type_id);
	}
	return qlite_update_builder_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

