Uniformize and fix ZrmErrors references.
This commit is contained in:
parent
1f6125d2e1
commit
c6db34694a
6 changed files with 16 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
const std = @import("std");
|
||||
const _sql = @import("sql.zig");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
|
||||
const Static = @This();
|
||||
|
||||
|
@ -78,7 +78,7 @@ pub fn in(comptime ValueType: type, allocator: std.mem.Allocator, _column: []con
|
|||
fn conditionsCombiner(comptime keyword: []const u8, allocator: std.mem.Allocator, subconditions: []const _sql.RawQuery) !_sql.RawQuery {
|
||||
if (subconditions.len == 0) {
|
||||
// At least one condition is required.
|
||||
return errors.ZrmError.AtLeastOneConditionRequired;
|
||||
return ZrmError.AtLeastOneConditionRequired;
|
||||
}
|
||||
|
||||
// Full keyword constant.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const pg = @import("pg");
|
||||
const zollections = @import("zollections");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
const database = @import("database.zig");
|
||||
const postgresql = @import("postgresql.zig");
|
||||
const _sql = @import("sql.zig");
|
||||
|
@ -198,7 +198,7 @@ pub fn RepositoryInsert(comptime Model: type, comptime TableShape: type, comptim
|
|||
/// Set selected columns for RETURNING clause.
|
||||
pub fn returningColumns(self: *Self, _select: []const []const u8) void {
|
||||
if (_select.len == 0) {
|
||||
return errors.AtLeastOneSelectionRequired;
|
||||
return ZrmError.AtLeastOneSelectionRequired;
|
||||
}
|
||||
|
||||
self.returning(.{
|
||||
|
@ -220,7 +220,7 @@ pub fn RepositoryInsert(comptime Model: type, comptime TableShape: type, comptim
|
|||
pub fn buildSql(self: *Self) !void {
|
||||
if (self.insertConfig.values.len == 0) {
|
||||
// At least one value is required to insert.
|
||||
return errors.ZrmError.AtLeastOneValueRequired;
|
||||
return ZrmError.AtLeastOneValueRequired;
|
||||
}
|
||||
|
||||
// Compute VALUES parameters count.
|
||||
|
|
|
@ -2,7 +2,7 @@ const std = @import("std");
|
|||
const pg = @import("pg");
|
||||
const zollections = @import("zollections");
|
||||
const global = @import("global.zig");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
const database = @import("database.zig");
|
||||
const _sql = @import("sql.zig");
|
||||
const _relationships = @import("relationships.zig");
|
||||
|
@ -51,7 +51,7 @@ pub fn handleRawPostgresqlError(err: anyerror, connection: *pg.Conn) anyerror {
|
|||
}
|
||||
|
||||
// Return that an error happened in query execution.
|
||||
return errors.ZrmError.QueryFailed;
|
||||
return ZrmError.QueryFailed;
|
||||
} else {
|
||||
// Not an SQL error, just return it.
|
||||
return err;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const pg = @import("pg");
|
||||
const zollections = @import("zollections");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
const database = @import("database.zig");
|
||||
const postgresql = @import("postgresql.zig");
|
||||
const _sql = @import("sql.zig");
|
||||
|
@ -105,7 +105,7 @@ pub fn RepositoryQuery(comptime Model: type, comptime TableShape: type, comptime
|
|||
/// Set selected columns for SELECT clause.
|
||||
pub fn selectColumns(self: *Self, _select: []const []const u8) !void {
|
||||
if (_select.len == 0) {
|
||||
return errors.AtLeastOneSelectionRequired;
|
||||
return ZrmError.AtLeastOneSelectionRequired;
|
||||
}
|
||||
|
||||
self.select(.{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
|
||||
/// A structure with SQL and its parameters.
|
||||
pub const RawQuery = struct {
|
||||
|
@ -120,7 +120,7 @@ pub const RawQueryParameter = union(enum) {
|
|||
null: void,
|
||||
|
||||
/// Convert any value to a query parameter.
|
||||
pub fn fromValue(value: anytype) errors.ZrmError!RawQueryParameter {
|
||||
pub fn fromValue(value: anytype) ZrmError!RawQueryParameter {
|
||||
// Get given value type.
|
||||
const valueType = @typeInfo(@TypeOf(value));
|
||||
|
||||
|
@ -138,7 +138,7 @@ pub const RawQueryParameter = union(enum) {
|
|||
if (pointer.child == u8) {
|
||||
return .{ .string = value };
|
||||
} else {
|
||||
return errors.ZrmError.UnsupportedTableType;
|
||||
return ZrmError.UnsupportedTableType;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -154,7 +154,7 @@ pub const RawQueryParameter = union(enum) {
|
|||
return .{ .null = true };
|
||||
}
|
||||
},
|
||||
else => return errors.ZrmError.UnsupportedTableType
|
||||
else => return ZrmError.UnsupportedTableType
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const pg = @import("pg");
|
||||
const zollections = @import("zollections");
|
||||
const errors = @import("errors.zig");
|
||||
const ZrmError = @import("errors.zig").ZrmError;
|
||||
const database = @import("database.zig");
|
||||
const postgresql = @import("postgresql.zig");
|
||||
const _sql = @import("sql.zig");
|
||||
|
@ -155,7 +155,7 @@ pub fn RepositoryUpdate(comptime Model: type, comptime TableShape: type, comptim
|
|||
/// Set selected columns for RETURNING clause.
|
||||
pub fn returningColumns(self: *Self, _select: []const []const u8) void {
|
||||
if (_select.len == 0) {
|
||||
return errors.AtLeastOneSelectionRequired;
|
||||
return ZrmError.AtLeastOneSelectionRequired;
|
||||
}
|
||||
|
||||
self.returning(.{
|
||||
|
@ -177,7 +177,7 @@ pub fn RepositoryUpdate(comptime Model: type, comptime TableShape: type, comptim
|
|||
pub fn buildSql(self: *Self) !void {
|
||||
if (self.updateConfig.value) |_| {} else {
|
||||
// Updated values must be set.
|
||||
return errors.ZrmError.UpdatedValuesRequired;
|
||||
return ZrmError.UpdatedValuesRequired;
|
||||
}
|
||||
|
||||
// Start parameter counter at 1.
|
||||
|
|
Loading…
Reference in a new issue