Uniformize and fix ZrmErrors references.

This commit is contained in:
Madeorsk 2025-01-12 23:56:37 +01:00
parent 1f6125d2e1
commit c6db34694a
Signed by: Madeorsk
GPG key ID: 677E51CA765BB79F
6 changed files with 16 additions and 16 deletions

View file

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
const _sql = @import("sql.zig"); const _sql = @import("sql.zig");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
const Static = @This(); 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 { fn conditionsCombiner(comptime keyword: []const u8, allocator: std.mem.Allocator, subconditions: []const _sql.RawQuery) !_sql.RawQuery {
if (subconditions.len == 0) { if (subconditions.len == 0) {
// At least one condition is required. // At least one condition is required.
return errors.ZrmError.AtLeastOneConditionRequired; return ZrmError.AtLeastOneConditionRequired;
} }
// Full keyword constant. // Full keyword constant.

View file

@ -1,7 +1,7 @@
const std = @import("std"); const std = @import("std");
const pg = @import("pg"); const pg = @import("pg");
const zollections = @import("zollections"); const zollections = @import("zollections");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
const database = @import("database.zig"); const database = @import("database.zig");
const postgresql = @import("postgresql.zig"); const postgresql = @import("postgresql.zig");
const _sql = @import("sql.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. /// Set selected columns for RETURNING clause.
pub fn returningColumns(self: *Self, _select: []const []const u8) void { pub fn returningColumns(self: *Self, _select: []const []const u8) void {
if (_select.len == 0) { if (_select.len == 0) {
return errors.AtLeastOneSelectionRequired; return ZrmError.AtLeastOneSelectionRequired;
} }
self.returning(.{ self.returning(.{
@ -220,7 +220,7 @@ pub fn RepositoryInsert(comptime Model: type, comptime TableShape: type, comptim
pub fn buildSql(self: *Self) !void { pub fn buildSql(self: *Self) !void {
if (self.insertConfig.values.len == 0) { if (self.insertConfig.values.len == 0) {
// At least one value is required to insert. // At least one value is required to insert.
return errors.ZrmError.AtLeastOneValueRequired; return ZrmError.AtLeastOneValueRequired;
} }
// Compute VALUES parameters count. // Compute VALUES parameters count.

View file

@ -2,7 +2,7 @@ const std = @import("std");
const pg = @import("pg"); const pg = @import("pg");
const zollections = @import("zollections"); const zollections = @import("zollections");
const global = @import("global.zig"); const global = @import("global.zig");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
const database = @import("database.zig"); const database = @import("database.zig");
const _sql = @import("sql.zig"); const _sql = @import("sql.zig");
const _relationships = @import("relationships.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 that an error happened in query execution.
return errors.ZrmError.QueryFailed; return ZrmError.QueryFailed;
} else { } else {
// Not an SQL error, just return it. // Not an SQL error, just return it.
return err; return err;

View file

@ -1,7 +1,7 @@
const std = @import("std"); const std = @import("std");
const pg = @import("pg"); const pg = @import("pg");
const zollections = @import("zollections"); const zollections = @import("zollections");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
const database = @import("database.zig"); const database = @import("database.zig");
const postgresql = @import("postgresql.zig"); const postgresql = @import("postgresql.zig");
const _sql = @import("sql.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. /// Set selected columns for SELECT clause.
pub fn selectColumns(self: *Self, _select: []const []const u8) !void { pub fn selectColumns(self: *Self, _select: []const []const u8) !void {
if (_select.len == 0) { if (_select.len == 0) {
return errors.AtLeastOneSelectionRequired; return ZrmError.AtLeastOneSelectionRequired;
} }
self.select(.{ self.select(.{

View file

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
/// A structure with SQL and its parameters. /// A structure with SQL and its parameters.
pub const RawQuery = struct { pub const RawQuery = struct {
@ -120,7 +120,7 @@ pub const RawQueryParameter = union(enum) {
null: void, null: void,
/// Convert any value to a query parameter. /// 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. // Get given value type.
const valueType = @typeInfo(@TypeOf(value)); const valueType = @typeInfo(@TypeOf(value));
@ -138,7 +138,7 @@ pub const RawQueryParameter = union(enum) {
if (pointer.child == u8) { if (pointer.child == u8) {
return .{ .string = value }; return .{ .string = value };
} else { } else {
return errors.ZrmError.UnsupportedTableType; return ZrmError.UnsupportedTableType;
} }
} }
}, },
@ -154,7 +154,7 @@ pub const RawQueryParameter = union(enum) {
return .{ .null = true }; return .{ .null = true };
} }
}, },
else => return errors.ZrmError.UnsupportedTableType else => return ZrmError.UnsupportedTableType
}; };
} }
}; };

View file

@ -1,7 +1,7 @@
const std = @import("std"); const std = @import("std");
const pg = @import("pg"); const pg = @import("pg");
const zollections = @import("zollections"); const zollections = @import("zollections");
const errors = @import("errors.zig"); const ZrmError = @import("errors.zig").ZrmError;
const database = @import("database.zig"); const database = @import("database.zig");
const postgresql = @import("postgresql.zig"); const postgresql = @import("postgresql.zig");
const _sql = @import("sql.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. /// Set selected columns for RETURNING clause.
pub fn returningColumns(self: *Self, _select: []const []const u8) void { pub fn returningColumns(self: *Self, _select: []const []const u8) void {
if (_select.len == 0) { if (_select.len == 0) {
return errors.AtLeastOneSelectionRequired; return ZrmError.AtLeastOneSelectionRequired;
} }
self.returning(.{ self.returning(.{
@ -177,7 +177,7 @@ pub fn RepositoryUpdate(comptime Model: type, comptime TableShape: type, comptim
pub fn buildSql(self: *Self) !void { pub fn buildSql(self: *Self) !void {
if (self.updateConfig.value) |_| {} else { if (self.updateConfig.value) |_| {} else {
// Updated values must be set. // Updated values must be set.
return errors.ZrmError.UpdatedValuesRequired; return ZrmError.UpdatedValuesRequired;
} }
// Start parameter counter at 1. // Start parameter counter at 1.