diff --git a/addons/gdata_orm/condition.gd b/addons/gdata_orm/condition.gd deleted file mode 100644 index c9669c2e..00000000 --- a/addons/gdata_orm/condition.gd +++ /dev/null @@ -1,196 +0,0 @@ -@tool -extends RefCounted -class_name Condition -## A programatically way to define Conditions. -## -## Condition is a way to define SQL Statements to be used with GDataORM. You can create -## full SQL Statements, or Simple conditions to be used when fetching data from the [SQLite] -## database.[br][br] -## -## [b]Example:[/b] -## [codeblock] -## var fetch_like_mar: Condition = Condition.new().select("*").from("my_table").where() \ -## .like("name", "Mar%") -## var fetch_gold: Condition = Condition.new().select(["gold"]).from("inventories").where() \ -## .greater("gold",0) -## var low_health: Condition = Condition.new().lesser("health",5) -## var mid_health: Condition = Condition.new().between("health",25,75) -## var full_health: Condition = Condition.new().greater_equal("health",100) -## [/codeblock] - -enum _CT { - NOT, - EQUAL, - LESS_THAN, - GREATER_THAN, - LESS_THAN_EQUAL, - GREATER_THAN_EQUAL, - AND, - BETWEEN, - IN, - LIKE, - OR, - SELECT, - FROM, - WHERE, -} - -var _conditions: Array = [] - -func _single_op(op: _CT) -> Dictionary: - return {"type": op} - -func _param_op(op: _CT, param: Variant) -> Dictionary: - return {"type": op, "param": param} - -func _comparison_op(op: _CT, column: Variant, value: Variant) -> Dictionary: - return {"type": op, "column": column, "value": value} - -## Binary operator to invert true and false in a statement. -func is_not() -> Condition: - _conditions.append(_single_op(_CT.NOT)) - return self - -## Evaluates the equality of a [param column] value and the [param value] given. -func equal(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.EQUAL, column, value)) - return self - -## Evaluates the [param column] value to be lesser than [param value] given. -func lesser(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.LESS_THAN, column, value)) - return self - -## Evaluates the [param column] value to be greater than [param value] given. -func greater(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.GREATER_THAN, column, value)) - return self - -## Evaluates the [param column] value to be lesser than or equal to [param value] given. -func lesser_equal(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.LESS_THAN_EQUAL, column, value)) - return self - -## Evaluates the [param column] value to be greater than or equal to [param value] given. -func greater_equal(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.GREATER_THAN_EQUAL, column, value)) - return self - -## Binary operator for AND'ing two evaluation values together. -func also() -> Condition: - _conditions.append(_single_op(_CT.AND)) - return self - -## Evaluates the [param column] value to be between [param lower]'s value and [param upper]'s value. -func between(column: String, lower: Variant, upper: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.BETWEEN, column, [lower, upper])) - return self - -## Evaluates the [param column] to see if [param value] is included in it. You can pass an array -## of values to this, or use a [Condition] to fetch data from another table. -func includes(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.IN, column, value)) - return self - -## Evaluates the [param column] to see if [param value] matches the given string. This utilizes -## [SQLite]'s LIKE statement, which means that you can use wildcard operators '%' and '_' in the -## pattern string.[br][br] -## [b]Wildcard Patterns:[/b][br] -## - '%' match any 1 or more characters in a pattern, EG: "Mar%" will return "Mario", "Mark", "Margin" etc etc.[br] -## - '_' match only 1 wildcard character before moving to the next. EG: "h_nt" will return "hunt", "hint", or -## "__pple" will return "topple", "supple", "tipple"[br] -## [b][color=red]NOTE:[/color][/b] [SQLite]'s engine is case-insensitive, so [code]"A" LIKE "a"[/code] will return true, but -## unicode characters that are not in the ASCII range are case-sensitive, so [code]"Ä" LIKE "ä"[/code] will return false. -func like(column: String, value: Variant) -> Condition: - _conditions.append(_comparison_op(_CT.LIKE, column, value)) - return self - -## Binary operator for OR'ing two evaluations together. -func otherwise() -> Condition: - _conditions.append(_single_op(_CT.OR)) - return self - -## Statement, fetches [param columns] from a table during execution. [param columns] can be a string value of "*" or "column1, column2, column3" or an -## array of strings such as ["column1","column2","column3"]. -func select(columns: Variant) -> Condition: - _conditions.append(_param_op(_CT.SELECT, columns)) - return self - -## Statement Modifier, used in conjunction with [method Condition.select] to define which table the data is to be fetched from. -func from(table: String) -> Condition: - _conditions.append(_param_op(_CT.FROM, table)) - return self - -## Statement Modifier, defines the conditions that must match in order to fetch data from the table. -func where() -> Condition: - _conditions.append(_single_op(_CT.WHERE)) - return self - -func _to_string() -> String: - var str = "" - var pos := 0 - - for cond in _conditions: - match cond.type: - #NOTE Single Operation _single_op() - _CT.NOT: - if _conditions[pos+1].type == _CT.BETWEEN: - pos += 1 - continue - str += "NOT " - _CT.AND: - str += "AND " - _CT.OR: - str += "OR " - _CT.WHERE: - str += "WHERE " - - #NOTE Param Operation _param_op() - _CT.SELECT: - var param = "" - if cond.param is Array: - param = ", ".join(cond.param) - elif cond.param is String: - param = cond.param - else: - assert(false, "SELECT statement only takes a String or Array parameters.") - str += "SELECT %s " % param - _CT.FROM: - str += "FROM %s " % cond.param - - #NOTE Comparison Operation _comparison_op() - _CT.EQUAL: - if typeof(cond.value) == TYPE_STRING: - str += "%s = '%s'" % [cond.column, cond.value] - else: - str += "%s = %s " % [cond.column, cond.value] - _CT.LESS_THAN: - str += "%s < %s " % [cond.column, cond.value] - _CT.GREATER_THAN: - str += "%s > %s " % [cond.column, cond.value] - _CT.LESS_THAN_EQUAL: - str += "%s <= %s " % [cond.column, cond.value] - _CT.GREATER_THAN_EQUAL: - str += "%s >= %s " % [cond.column, cond.value] - _CT.BETWEEN: - if _conditions[pos-1].type == _CT.NOT: - str += "%s NOT BETWEEN " % cond.column - else: - str += "%s BETWEEN " % cond.column - str += "%s and %s" % cond.value - _CT.IN: - if _conditions[pos-1].type == _CT.NOT: - str += "%s NOT IN " % cond.column - else: - str += "%s IN " % cond.column - if cond.value is Condition: - str += "(%s) " % cond.value.to_string() - elif cond.value is Array: - str += "(%s) " % ", ".join(cond.value) - else: - assert(false, "IN only takes Array of values or a Condition") - _CT.LIKE: - str += "%s LIKE '%s' " % [cond.column, cond.value] - pos += 1 - - return str.strip_edges() diff --git a/addons/gdata_orm/condition.gd.uid b/addons/gdata_orm/condition.gd.uid deleted file mode 100644 index bf91c59c..00000000 --- a/addons/gdata_orm/condition.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b3fmxmewptm3k diff --git a/addons/gdata_orm/context.gd b/addons/gdata_orm/context.gd deleted file mode 100644 index 22022ffd..00000000 --- a/addons/gdata_orm/context.gd +++ /dev/null @@ -1,86 +0,0 @@ -extends RefCounted -class_name Context -## The Central core for interacting with Databases. -## -## Context is the class which creates a Database Connection to a [SQLite] database, -## and sets up all tables as defined by the DbSet definitions of the class.[br][br] -## -## [b]Example:[/b] -## [codeblock] -## extends Context -## class_name AppContext -## -## var characters: DbSet -## var inventories: DbSet -## var items: DbSet -## -## func _init() -> void: -## characters = DbSet.new(Character) -## inventories = DbSet.new(Inventory) -## items = DbSet.new(Item) -## -## [/codeblock] - -## The path in which to find the database, Example: `my_context.file_path = "user://my_database.db"` -@export var file_path: String - -var _db: SQLite - -## Called to initialize the Context. This should be called just after the creation of the context, in order to -## register all [DbSet]'s with the Context, as well, as call [method SQLiteObject.setup] on all SQLiteObject's -## that have been defined as a DbSet of this class. -func setup() -> void: - var props = get_property_list() - for prop in props: - if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: - continue - if prop.type != TYPE_OBJECT or prop.class_name != "DbSet": - continue - - var dbset: DbSet = get(prop.name) - dbset._klass.setup(dbset._klass) - -## Opens the [SQLite] database, allowing for the usages of the [DbSet]s defined in this context. -func open_db(db_path: String = "") -> void: - var props = get_property_list() - if db_path != "": - file_path = db_path - _db = SQLite.new() - _db.path = file_path - _db.open_db() - for prop in props: - if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: - continue - if prop.type != TYPE_OBJECT or prop.class_name != "DbSet": - continue - var dbset: DbSet = get(prop.name) - dbset.set_db(_db) - -## Closes the database when finished interacting with this instance. -func close_db() -> void: - _db.close_db() - - -## Ensures that all tables defined as [DbSet] in this context, are properly created in the database. -func ensure_tables() -> void: - var props = get_property_list() - for prop in props: - if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: - continue - if prop.type != TYPE_OBJECT or prop.class_name != "DbSet": - continue - var dbset: DbSet = get(prop.name) - if not dbset.table_exists(): - dbset.create_table(false) - -## Forces the creation of all tables defined as [DbSet] in this context, are properly created, dropping -## the table if it already exists. -func force_create_tables() -> void: - var props = get_property_list() - for prop in props: - if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: - continue - if prop.type != TYPE_OBJECT or prop.class_name != "DbSet": - continue - var dbset: DbSet = get(prop.name) - dbset.create_table(true) diff --git a/addons/gdata_orm/context.gd.uid b/addons/gdata_orm/context.gd.uid deleted file mode 100644 index 34df299c..00000000 --- a/addons/gdata_orm/context.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://baaxskalxregg diff --git a/addons/gdata_orm/db_set.gd b/addons/gdata_orm/db_set.gd deleted file mode 100644 index 87a9ef87..00000000 --- a/addons/gdata_orm/db_set.gd +++ /dev/null @@ -1,86 +0,0 @@ -@tool -extends Resource -class_name DbSet -## A Central point for fetching/storing [SQLiteObject]s in a Database. -## -## DbSet is used to create a link between [SQLiteObject]s and the tables they are stored in. Functions for -## inserting, fetching, and removing [SQLiteObject]s in a database, along with support functions for checking -## if a table exists, and creating tables.[br][br] -## -## [b]Example:[/b] -## [codeblock] -## extends Context -## class_name AppContext -## -## var characters: DbSet -## var inventories: DbSet -## var items: DbSet -## -## func _init() -> void: -## characters = DbSet.new(Character) -## inventories = DbSet.new(Inventory) -## items = DbSet.new(Item) -## -## [/codeblock] - -var _klass: GDScript -var _db: SQLite - -## Create an instance of DbSet, specifying the [SQLiteObject] inherited class that represents -## the table that this set should interact with. -func _init(h_klass: GDScript) -> void: - _klass = h_klass - -## Set the [SQLite] database handle for this [DbSet]. This is handled internally by [method Context.setup], -## but you can also set a custom database handle for this DbSet. -func set_db(db_conn: SQLite) -> void: - _db = db_conn - -## Creates the backing table for the [SQLiteObject] inherited backing class for the object. -func create_table(drop_if_exists: bool) -> void: - SQLiteObject._create_table(_db, _klass, drop_if_exists) - -## Check to see if the table exists or not. -func table_exists() -> bool: - return SQLiteObject._table_exists(_db, _klass) - -## Check's the [SQLite] database to see if the ID exists in the database. Require's [method SQLiteObject.set_column_flags] -## being called assigning a column as a Primary Key. -func has_id(id: Variant) -> bool: - return SQLiteObject._has_id(_db, _klass, id) - -## Searches the [SQLite] database for an object that matches the [Condition] as given. Returns the -## [SQLiteObject] instance if found, otherwise returns null if it found nothing. -func find_one(conditions: Condition) -> SQLiteObject: - return SQLiteObject._find_one(_db, _klass, conditions) - -## Searches the [SQLite] database for any matching object that matches the [Condition] given. Returns -## an Array of [SQLiteObject]s that was found, otherwise returns an Empty array if nothing is found. -func find_many(conditions: Condition) -> Array: - return SQLiteObject._find_many(_db, _klass, conditions) - -## Returns all saved [SQLiteObject]s stored in the [SQLite] database. -func all() -> Array: - return SQLiteObject._all(_db, _klass) - -## Stores a [SQLiteObject] in the [SQLite] database. Until this is called, an [SQLiteObject] is not -## saved in the database, and [method SQLiteObject.save] will not work. Using this method will -## automatically save the data to the Database when executed.[br][br] -## [b][color=red]NOTE:[/color][/b] [SQLiteObject]s defined with an Auto-Increment Primary key, will -## set their primary key variable once this method is run automatically for you. If the primary -## key is not set after calling this method, then it was not saved to the database. -func append(obj: SQLiteObject) -> void: - assert(obj.get_script() == _klass, "Attempting to add an SQLiteObject of %s to table of type %s!" % - [obj.get_script().get_global_name(), _klass.get_global_name()] - ) - obj._db = _db - obj.save() - -## Removes a [SQLiteObject] from the [SQLite] database. This function calls [method SQLiteObject.delete] -## function to remove it from the database. You can use either method to remove the object from the database. -func erase(obj: SQLiteObject) -> void: - assert(obj.get_script() == _klass, "Attempting to remove an SQLiteObject of %s to table of type %s!" % - [obj.get_script().get_global_name(), _klass.get_global_name()] - ) - obj._db = _db - obj.delete() diff --git a/addons/gdata_orm/db_set.gd.uid b/addons/gdata_orm/db_set.gd.uid deleted file mode 100644 index 196f4bc3..00000000 --- a/addons/gdata_orm/db_set.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://c2buvo3nsojg diff --git a/addons/gdata_orm/godot-sqlite/LICENSE.md b/addons/gdata_orm/godot-sqlite/LICENSE.md deleted file mode 100644 index 68d6eb5f..00000000 --- a/addons/gdata_orm/godot-sqlite/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019-2024 Piet Bronders & Jeroen De Geeter - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.arm64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.arm64.so deleted file mode 100644 index 728daa29..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.arm64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.x86_64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.x86_64.so deleted file mode 100644 index d3866b9d..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_debug.x86_64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.arm64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.arm64.so deleted file mode 100644 index ab4b36aa..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.arm64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.x86_64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.x86_64.so deleted file mode 100644 index 326bb4e6..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.android.template_release.x86_64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.arm64.dylib b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.arm64.dylib deleted file mode 100644 index 2110e9ef..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.arm64.dylib and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/Info.plist deleted file mode 100644 index 31fa2a96..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - AvailableLibraries - - - BinaryPath - libgdsqlite.ios.template_debug.a - LibraryIdentifier - ios-arm64 - LibraryPath - libgdsqlite.ios.template_debug.a - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - BinaryPath - libgdsqlite.ios.template_debug.simulator.a - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - libgdsqlite.ios.template_debug.simulator.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64/libgdsqlite.ios.template_debug.a b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64/libgdsqlite.ios.template_debug.a deleted file mode 100644 index 1f73c449..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64/libgdsqlite.ios.template_debug.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_debug.simulator.a b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_debug.simulator.a deleted file mode 100644 index ea105313..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_debug.simulator.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.arm64.dylib b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.arm64.dylib deleted file mode 100644 index 07641a68..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.arm64.dylib and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/Info.plist deleted file mode 100644 index c75d2c21..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - AvailableLibraries - - - BinaryPath - libgdsqlite.ios.template_release.a - LibraryIdentifier - ios-arm64 - LibraryPath - libgdsqlite.ios.template_release.a - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - BinaryPath - libgdsqlite.ios.template_release.simulator.a - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - libgdsqlite.ios.template_release.simulator.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64/libgdsqlite.ios.template_release.a b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64/libgdsqlite.ios.template_release.a deleted file mode 100644 index b7925bd0..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64/libgdsqlite.ios.template_release.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_release.simulator.a b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_release.simulator.a deleted file mode 100644 index 5032da13..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgdsqlite.ios.template_release.simulator.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_debug.x86_64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_debug.x86_64.so deleted file mode 100644 index 040ef578..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_debug.x86_64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_release.x86_64.so b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_release.x86_64.so deleted file mode 100644 index 361fb3a9..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.linux.template_release.x86_64.so and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/Resources/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/Resources/Info.plist deleted file mode 100644 index 09949050..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/Resources/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleExecutable - libgdsqlite.template_debug - CFBundleIdentifier - org.godotengine.libgdsqlite - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - libgdsqlite.macos.template_debug - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSupportedPlatforms - - MacOSX - - CFBundleVersion - 1.0.0 - LSMinimumSystemVersion - 10.12 - - \ No newline at end of file diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libgdsqlite.macos.template_debug b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libgdsqlite.macos.template_debug deleted file mode 100644 index 5a2c5478..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libgdsqlite.macos.template_debug and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libmacos.libgdsqlite.template_debug b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libmacos.libgdsqlite.template_debug deleted file mode 100644 index 51d2de34..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_debug.framework/libmacos.libgdsqlite.template_debug and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/Resources/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/Resources/Info.plist deleted file mode 100644 index 59a03997..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/Resources/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleExecutable - libgdsqlite.template_release - CFBundleIdentifier - org.godotengine.libgdsqlite - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - libgdsqlite.macos.template_release - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0.0 - CFBundleSupportedPlatforms - - MacOSX - - CFBundleVersion - 1.0.0 - LSMinimumSystemVersion - 10.12 - - \ No newline at end of file diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libgdsqlite.macos.template_release b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libgdsqlite.macos.template_release deleted file mode 100644 index d5867947..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libgdsqlite.macos.template_release and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libmacos.libgdsqlite.template_release b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libmacos.libgdsqlite.template_release deleted file mode 100644 index c480fede..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.macos.template_release.framework/libmacos.libgdsqlite.template_release and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm deleted file mode 100644 index 194b9565..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.wasm b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.wasm deleted file mode 100644 index 1b0221b7..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_debug.wasm32.wasm and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm deleted file mode 100644 index 5ab37a67..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm deleted file mode 100644 index a7382d53..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.web.template_release.wasm32.wasm and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_debug.x86_64.dll b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_debug.x86_64.dll deleted file mode 100644 index 0fd29716..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_debug.x86_64.dll and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_release.x86_64.dll b/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_release.x86_64.dll deleted file mode 100644 index 02e1acc2..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgdsqlite.windows.template_release.x86_64.dll and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/Info.plist deleted file mode 100644 index 7c5615d1..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - AvailableLibraries - - - BinaryPath - libgodot-cpp.ios.template_debug.arm64.a - LibraryIdentifier - ios-arm64 - LibraryPath - libgodot-cpp.ios.template_debug.arm64.a - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - BinaryPath - libgodot-cpp.ios.template_debug.universal.simulator.a - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - libgodot-cpp.ios.template_debug.universal.simulator.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64/libgodot-cpp.ios.template_debug.arm64.a b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64/libgodot-cpp.ios.template_debug.arm64.a deleted file mode 100644 index 15c8dcda..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64/libgodot-cpp.ios.template_debug.arm64.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_debug.universal.simulator.a b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_debug.universal.simulator.a deleted file mode 100644 index 93cfcf8d..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_debug.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_debug.universal.simulator.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/Info.plist b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/Info.plist deleted file mode 100644 index dd571681..00000000 --- a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/Info.plist +++ /dev/null @@ -1,44 +0,0 @@ - - - - - AvailableLibraries - - - BinaryPath - libgodot-cpp.ios.template_release.arm64.a - LibraryIdentifier - ios-arm64 - LibraryPath - libgodot-cpp.ios.template_release.arm64.a - SupportedArchitectures - - arm64 - - SupportedPlatform - ios - - - BinaryPath - libgodot-cpp.ios.template_release.universal.simulator.a - LibraryIdentifier - ios-arm64_x86_64-simulator - LibraryPath - libgodot-cpp.ios.template_release.universal.simulator.a - SupportedArchitectures - - arm64 - x86_64 - - SupportedPlatform - ios - SupportedPlatformVariant - simulator - - - CFBundlePackageType - XFWK - XCFrameworkFormatVersion - 1.0 - - diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64/libgodot-cpp.ios.template_release.arm64.a b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64/libgodot-cpp.ios.template_release.arm64.a deleted file mode 100644 index 8d380b0f..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64/libgodot-cpp.ios.template_release.arm64.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_release.universal.simulator.a b/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_release.universal.simulator.a deleted file mode 100644 index 06d1f0b1..00000000 Binary files a/addons/gdata_orm/godot-sqlite/bin/libgodot-cpp.ios.template_release.xcframework/ios-arm64_x86_64-simulator/libgodot-cpp.ios.template_release.universal.simulator.a and /dev/null differ diff --git a/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension b/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension deleted file mode 100644 index 3c48afcf..00000000 --- a/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension +++ /dev/null @@ -1,32 +0,0 @@ -[configuration] - -entry_symbol = "sqlite_library_init" -compatibility_minimum = "4.4" - -[libraries] - -macos.debug = "./bin/libgdsqlite.macos.template_debug.framework" -macos.release = "./bin/libgdsqlite.macos.template_release.framework" -windows.debug.x86_64 = "./bin/libgdsqlite.windows.template_debug.x86_64.dll" -windows.release.x86_64 = "./bin/libgdsqlite.windows.template_release.x86_64.dll" -linux.debug.x86_64 = "./bin/libgdsqlite.linux.template_debug.x86_64.so" -linux.release.x86_64 = "./bin/libgdsqlite.linux.template_release.x86_64.so" -android.debug.arm64 = "./bin/libgdsqlite.android.template_debug.arm64.so" -android.release.arm64 = "./bin/libgdsqlite.android.template_release.arm64.so" -android.debug.x86_64 = "./bin/libgdsqlite.android.template_debug.x86_64.so" -android.release.x86_64 = "./bin/libgdsqlite.android.template_release.x86_64.so" -ios.debug = "./bin/libgdsqlite.ios.template_debug.xcframework" -ios.release = "./bin/libgdsqlite.ios.template_release.xcframework" -web.debug.threads.wasm32 = "./bin/libgdsqlite.web.template_debug.wasm32.wasm" -web.release.threads.wasm32 = "./bin/libgdsqlite.web.template_release.wasm32.wasm" -web.debug.wasm32 = "./bin/libgdsqlite.web.template_debug.wasm32.nothreads.wasm" -web.release.wasm32 = "./bin/libgdsqlite.web.template_release.wasm32.nothreads.wasm" - -[dependencies] - -ios.debug = { - "./bin/libgodot-cpp.ios.template_debug.xcframework": "" -} -ios.release = { - "./bin/libgodot-cpp.ios.template_release.xcframework": "" -} diff --git a/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension.uid b/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension.uid deleted file mode 100644 index 2af72abb..00000000 --- a/addons/gdata_orm/godot-sqlite/gdsqlite.gdextension.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ca6ikrilfs4se diff --git a/addons/gdata_orm/godot-sqlite/godot-sqlite.gd b/addons/gdata_orm/godot-sqlite/godot-sqlite.gd deleted file mode 100644 index 95821138..00000000 --- a/addons/gdata_orm/godot-sqlite/godot-sqlite.gd +++ /dev/null @@ -1,14 +0,0 @@ -# ############################################################################ # -# Copyright © 2019-2025 Piet Bronders & Jeroen De Geeter -# Licensed under the MIT License. -# See LICENSE in the project root for license information. -# ############################################################################ # - -@tool -extends EditorPlugin - -func _enter_tree(): - pass - -func _exit_tree(): - pass diff --git a/addons/gdata_orm/godot-sqlite/godot-sqlite.gd.uid b/addons/gdata_orm/godot-sqlite/godot-sqlite.gd.uid deleted file mode 100644 index 029b6578..00000000 --- a/addons/gdata_orm/godot-sqlite/godot-sqlite.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://cwsfv71x0jo4e diff --git a/addons/gdata_orm/godot-sqlite/plugin.cfg b/addons/gdata_orm/godot-sqlite/plugin.cfg deleted file mode 100644 index 7a86a76d..00000000 --- a/addons/gdata_orm/godot-sqlite/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="Godot SQLite" -description="GDNative wrapper for SQLite (Godot 4.X+), making it possible to use SQLite databases as data storage in all your future games." -author="Piet Bronders & Jeroen De Geeter" -version="4.5" -script="godot-sqlite.gd" diff --git a/addons/gdata_orm/plugin.cfg b/addons/gdata_orm/plugin.cfg deleted file mode 100644 index 71d6ef3b..00000000 --- a/addons/gdata_orm/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="GDataORM" -description="Godot based Data ORM (Object-Relational-Mapping) system based on SQLite." -author="Mario Steele" -version="0.1" -script="plugin.gd" diff --git a/addons/gdata_orm/plugin.gd b/addons/gdata_orm/plugin.gd deleted file mode 100644 index ced9555f..00000000 --- a/addons/gdata_orm/plugin.gd +++ /dev/null @@ -1,23 +0,0 @@ -@tool -extends EditorPlugin - - -func _enable_plugin() -> void: - EditorInterface.set_plugin_enabled("./godot-sqlite", true) - pass - - -func _disable_plugin() -> void: - EditorInterface.set_plugin_enabled("./godot-sqlite", false) - # Remove autoloads here. - pass - - -func _enter_tree() -> void: - # Initialization of the plugin goes here. - pass - - -func _exit_tree() -> void: - # Clean-up of the plugin goes here. - pass diff --git a/addons/gdata_orm/plugin.gd.uid b/addons/gdata_orm/plugin.gd.uid deleted file mode 100644 index 27dc6531..00000000 --- a/addons/gdata_orm/plugin.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://6kjkv8ueyjhd diff --git a/addons/gdata_orm/sqlite_object.gd b/addons/gdata_orm/sqlite_object.gd deleted file mode 100644 index f403e4e8..00000000 --- a/addons/gdata_orm/sqlite_object.gd +++ /dev/null @@ -1,431 +0,0 @@ -extends Resource -class_name SQLiteObject -## A Data Object representative of data to store in [SQLite] database. -## -## [SQLiteObject] is the core class for GDataORM. It handles the grunt work -## of defining what table structure is and any special flags that are needed -## for SQLite.[br][br] -## -## [b]Example:[/b] -## [codeblock] -## extends SQLiteObject -## class_name Account -## -## var id: int -## var username: String -## var password: String -## var address: Address -## -## static func _setup() -> void: -## set_table_name(Account, "accounts") -## set_column_flags(Account, "id", Flags.PRIMARY_KEY | Flags.AUTO_INCREMENT | Flags.NOT_NULL) -## set_column_flags(Account, "username", Flags.NOT_NULL) -## set_column_flags(Account, "password", Flags.NOT_NULL) -## [/codeblock] - -## The supported types of [SQLiteObject] -enum DataType { - ## A [bool] Value - BOOL, - ## An [int] Value - INT, - ## A [float] Value - REAL, - ## A Variable Length [String] Value - STRING, - ## A [Dictionary] Value - DICTIONARY, - ## An [Array] Value - ARRAY, - ## A value of a built-in Godot DataType, or Object of a Custom Class. - GODOT_DATATYPE, - ## A Fixed-size [String] value, like [PackedStringArray] - CHAR, - ## A Binary value, like [PackedByteArray] - BLOB -} - -const _BaseTypes = { - TYPE_BOOL: DataType.BOOL, - TYPE_INT: DataType.INT, - TYPE_FLOAT: DataType.REAL, - TYPE_STRING: DataType.STRING, - TYPE_DICTIONARY: DataType.DICTIONARY, - TYPE_ARRAY: DataType.ARRAY, -} - -const _DEFINITION = [ - "int", - "int", - "real", - "text", - "text", - "text", - "blob", - "char(%d)", - "blob" -] - -## SQLite flags used for column definitions. -enum Flags { - ## No Flags Associated with this Column - NONE = 1 << 0, - ## Column must not be Null. - NOT_NULL = 1 << 1, - ## Column must be Unique - UNIQUE = 1 << 2, - ## Column has a Default value. - DEFAULT = 1 << 3, - ## Column is defined as a Primary Key for this table. - PRIMARY_KEY = 1 << 4, - ## Column is defined as auto-incrementing. - AUTO_INCREMENT = 1 << 5, - ## Column is a Foreign Key (See [SQLite] about Foreign Keys) - FOREIGN_KEY = 1 << 6, -} - -class TableDefs: - var columns: Dictionary[String, Dictionary] = {} - var types: Dictionary[String, DataType] = {} - var klass: GDScript - var table_name: String - -static var _tables: Dictionary[GDScript, TableDefs] = {} -static var _registry: Dictionary[String, GDScript] = {} -var _db: SQLite - -## A debugging utility to see what classes have been registered with [SQLiteObject]. -## This is printed out to the terminal/output window for easy review. -static func print_registered_classes() -> void: - print("SQLiteObject Registered Classes:") - for klass_name in _registry: - print(klass_name) - -## A debugging utility to see the structure of all the classes registered with [SQLiteObject]. -## This is printed out to the terminal/output window for easy review. -static func print_data_structure() -> void: - print("SQLite Object Data Structure:") - print("-----------------------------") - for klass in _tables: - var table = _tables[klass] - print("SQLiteObject>%s" % klass.get_global_name()) - print("Table Name: %s" % table.table_name) - print("COLUMNS:") - - for column in table.columns: - var keys: Array = table.columns[column].keys().filter(func(x): return x != "data_type") - var columns := [table.columns[column].data_type] - columns.append_array(keys) - print("\t%s(DataType.%s) - SQLite: (%s)" % [ - column, - DataType.find_key(table.types[column]), - ", ".join(columns) - ]) - print("") - pass - -## This function is called once when setting up the class. This is automatically done with classes -## that are registered as a [DbSet] by the [method Context.setup] static function call. -static func setup(klass: GDScript) -> void: - _registry[klass.get_global_name()] = klass - var table: TableDefs - if _tables.has(klass): - table = _tables[klass] - else: - table = TableDefs.new() - table.klass = klass - table.table_name = klass.get_global_name() - _tables[klass] = table - - for prop in klass.get_script_property_list(): - if not prop.usage & PROPERTY_USAGE_SCRIPT_VARIABLE: - continue - - if prop.name.begins_with("_"): - continue - - var def = {} - if _BaseTypes.has(prop.type): - def.data_type = _DEFINITION[_BaseTypes[prop.type]] - table.types[prop.name] = _BaseTypes[prop.type] - else: - def.data_type = _DEFINITION[DataType.GODOT_DATATYPE] - table.types[prop.name] = DataType.GODOT_DATATYPE - - table.columns[prop.name] = def - - klass._setup() - -## This is a virtual function that is called when setup() is called. This allows you to -## setup the data class information such as Column Flags, Table Name and Column Types. -static func _setup() -> void: - push_warning("No setup has been defined for this class. No special column flags or types will be used.") - -## This function allows you to set SQLite specific flags for columns, when storing the data. -## This function should only be called in [method SQLiteObject._setup] which is part of the -## initialization of the data.[br][br] -## [b]Example:[/b] -## [codeblock] -## static func _setup() -> void: -## # Ensure ID is an Auto-Increment Primary key in the database, that is not allowed to be null. -## set_column_flag(MyDataClass, "id", Flags.PRIMARY_KEY | Flags.AUTO_INCREMENT | Flags.NOT_NULL) -## # Ensure that name is not null in the database, and that it doesn't match any other row of data. -## set_column_flag(MyDataClass, "name", Flags.NOT_NULL | Flags.UNIQUE) -## [/codeblock] -static func set_column_flags(klass: GDScript, column: String, flags: int, extra_params: Dictionary = {}) -> void: - assert(_tables.has(klass), "Setup must be called first, before setting any column flags!") - assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!") - - var data_type = _tables[klass].types[column] - var col_def = _tables[klass].columns[column] - - if flags & Flags.DEFAULT and not extra_params.has("default"): - assert(false,"Attempting to set a default, without defining it in extra parameters!") - if flags & Flags.AUTO_INCREMENT and not [DataType.INT, DataType.REAL].has(data_type): - assert(false, "Attempting to set Auto Increment flag on Non-Integer column!") - if flags & Flags.FOREIGN_KEY: - if not extra_params.has("table"): - assert(false, "Attempting to set Foreign Key flag without defining the Table it associates with!") - if not extra_params.has("foreign_key"): - assert(false, "Attempting to set Foreign Key flag without defining the Foreign Key!") - - - if flags & Flags.NOT_NULL: col_def.not_null = true - if flags & Flags.UNIQUE: col_def.unique = true - if flags & Flags.DEFAULT: col_def.default = extra_params.default - if flags & Flags.AUTO_INCREMENT: col_def.auto_increment = true - if flags & Flags.PRIMARY_KEY: col_def.primary_key = true - if flags & Flags.FOREIGN_KEY: - col_def.foreign_key = extra_params.foreign_key - col_def.foreign_table = extra_params.table - _tables[klass].columns[column] = col_def - -## Sets the table name to use in the [SQLite] database for storing/fetching data -## from the database. -static func set_table_name(klass: GDScript, table_name: String) -> void: - assert(_tables.has(klass), "Setup must be called first, before setting the table name!") - _tables[klass].table_name = table_name if table_name != "" else klass.get_global_name() - -## Sets the column type of [enum SQLiteObject.DataType] along with any extra parameters needed.[br][br] -## [b][color=red]NOTE:[/color][/b] Only use this function if you know what you are doing. GDataORM -## attempts to match the SQLite data type, with the Godot data type as best as possible. -static func set_column_type(klass: GDScript, column: String, type: DataType, extra_params: Dictionary = {}) -> void: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!") - - if type == DataType.CHAR and not extra_params.has("size"): - assert(false, "Attempting to set Column type to CHAR without a size parameter!") - - _tables[klass].types[column] = type - _tables[klass].columns[column].data_type = _DEFINITION[type] if type != DataType.CHAR else _DEFINITION[type] % extra_params.size - -## Sets a variable that has been defined in the class, to be ignored, so as to not persist the data in the -## [SQLite] database. The variable must be defined, in order for it to be ignored.[br][br] -## [b][color=red]NOTE:[/color][/b] By default, GDataORM ignore's any variables that start with [code]_[/code] character. -static func ignore_column(klass: GDScript, column: String) -> void: - assert(_tables.has(klass), "Setup must be called first, before ignoring any column types!") - assert(_tables[klass].columns.has(column), "Column has not been defined! Make sure to declare the variable first!") - - _tables[klass].types.erase(column) - _tables[klass].columns.erase(column) - -## Adds a variable that is normally ignored in the class, to not be ignoerd, so that it can persist the data -## in the [SQLite] database. The variable must be defined, in order for this function to succeed. -static func add_column(klass: GDScript, column: String) -> void: - assert(_tables.has(klass), "Setup must be called first, before adding any column types!") - var props = klass.get_property_list() - var res = props.filter(func(x): return x.name == column) - assert(res.size() > 0, "You cannot add a column, that does not have the variable defined for it!") - - var prop = res[0] - var def = {} - if _BaseTypes.has(prop.type): - def.data_type = _DEFINITION[_BaseTypes[prop.type]] - _tables[klass].types[prop.name] = _BaseTypes[prop.type] - else: - def.data_type = _DEFINITION[DataType.GODOT_DATATYPE] - _tables[klass].types[prop.name] = DataType.GODOT_DATATYPE - - _tables[klass].columns[prop.name] = def - -static func _create_table(db: SQLite, klass: GDScript, drop_if_exists = false) -> void: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - assert(not _tables[klass].columns.is_empty(), "No columns has been defined, either no variables are defined in the GDScript source, or setup was not called first!") - if _table_exists(db, klass): - if drop_if_exists: - db.drop_table(_tables[klass].table_name) - else: - assert(false, "Table already exists!") - db.create_table(_tables[klass].table_name, _tables[klass].columns) - -static func _table_exists(db: SQLite, klass: GDScript) -> bool: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - var table := _tables[klass] - db.query_with_bindings("SELECT name FROM sqlite_master WHERE type='table' AND name=?;", [table.table_name]) - return not db.query_result.is_empty() - -static func _has_id(db: SQLite, klass: GDScript, id: Variant) -> bool: - var primary_key = _get_primary_key(klass) - var table := _tables[klass] - if typeof(id) == TYPE_STRING: - db.query_with_bindings("SELECT ? FROM ? WHERE ?='?'", [primary_key, table.table_name, primary_key, id]) - else: - db.query_with_bindings("SELECT ? FROM ? WHERE ?=?;", [primary_key, table.table_name, primary_key, id]) - return not db.query_result.is_empty() - -static func _get_primary_key(klass: GDScript) -> String: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - var table := _tables[klass] - var primary_key: String = "" - for column in table.columns: - if table.columns[column].has("primary_key"): - primary_key = column - break - - assert(primary_key != "", "No primary key has been defined!") - return primary_key - -static func _populate_object(table: TableDefs, obj: SQLiteObject, data: Dictionary) -> void: - var props = obj.get_property_list() - for key in data: - if not props.any(func(x): return x.name == key): - continue - var prop = props.filter(func(x): return x.name == key)[0] - if (table.types[key] == DataType.ARRAY or - table.types[key] == DataType.DICTIONARY): - obj.get(key).assign(JSON.parse_string(data[key])) - elif table.types[key] == DataType.GODOT_DATATYPE: - if _registry.has(prop.class_name): - var klass := _registry[prop.class_name] - var cond := Condition.new() - var pk: String = _get_primary_key(klass) - cond.equal(pk, bytes_to_var(data[key])) - var nobj = _find_one(obj._db, klass, cond) - obj.set(key, nobj) - else: - obj.set(key, bytes_to_var(data[key])) - else: - obj.set(key, data[key]) - -static func _find_one(db: SQLite, klass: GDScript, conditions: Condition) -> SQLiteObject: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - var table := _tables[klass] - var res := db.select_rows(table.table_name, conditions.to_string(), table.columns.keys()) - - if res.is_empty(): - return null - else: - var obj = klass.new() - obj._db = db - _populate_object(table, obj, res[0]) - return obj - -static func _find_many(db: SQLite, klass: GDScript, conditions: Condition) -> Array: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - var table := _tables[klass] - var objs: Array = [] - var res = db.select_rows(table.table_name, conditions.to_string(), table.columns.keys()) - - for data in res: - var obj = klass.new() - obj._db = db - _populate_object(table, obj, data) - objs.append(obj) - return objs - -static func _all(db: SQLite, klass: GDScript) -> Array: - assert(_tables.has(klass), "Setup must be called first, before setting any column types!") - var table := _tables[klass] - var objs: Array = [] - var res = db.select_rows(table.table_name, "", table.columns.keys()) - - for data in res: - var obj = klass.new() - obj._db = db - _populate_object(table, obj, data) - objs.append(obj) - return objs - -## Verify that the [SQLiteObject] exists in the database. -func exists() -> bool: - assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!") - assert(_db, "exists(): This instance was not fetched from the database, or has not been added to a DbSet!") - var table := _tables[self.get_script()] - var primary_key = _get_primary_key(self.get_script()) - assert(primary_key != "", "A Primary Key has not been defined for this class.") - var res = _db.select_rows(table.table_name, - Condition.new().equal(primary_key, self.get(primary_key)).to_string(), - [primary_key]) - return not res.is_empty() - -## Saves the [SQLiteObject] to the database file.[br][br] -## [b][color=red]NOTE:[/color][/b] Of special note, an object needs to be added to a [DbSet] first through -## [method DbSet.append] for this function to work. [method DbSet.append] will save the object when -## it is first added. This function is mostly for recording updates to the [SQLiteObject] data. -func save() -> void: - assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!") - assert(_db, "save(): This instance was not fetched from the database, or has not been added to a DbSet!") - var table := _tables[self.get_script()] - var primary_key = _get_primary_key(self.get_script()) - - var sql_data = {} - var data: Variant - for key in table.columns.keys(): - data = get(key) - if (table.types[key] == DataType.ARRAY or - table.types[key] == DataType.DICTIONARY - ): - sql_data[key] = JSON.stringify(data) - elif table.types[key] == DataType.GODOT_DATATYPE: - if typeof(data) == TYPE_OBJECT: - if _registry.has(data.get_script().get_global_name()): - var pk := _get_primary_key(data.get_script()) - var pk_val = data.get(pk) - sql_data[key] = var_to_bytes(pk_val) - else: - sql_data[key] = var_to_bytes(data) - else: - sql_data[key] = var_to_bytes(data) - else: - sql_data[key] = data - - if primary_key != "" and exists(): - _db.update_rows(table.table_name,Condition.new().equal(primary_key, get(primary_key)).to_string(), sql_data) - else: - if primary_key != "" and table.columns[primary_key].auto_increment: - sql_data.erase(primary_key) - - _db.insert_row(table.table_name, sql_data) - - if primary_key != "" and table.columns[primary_key].auto_increment: - var cond := Condition.new().equal("name","%s" % table.table_name) - var res := _db.select_rows("sqlite_sequence", cond.to_string(), ["seq"]) - assert(not res.is_empty(), "Failed to insert record into %s." % [table.table_name]) - set(primary_key, res[0].seq) - -## Removes the [SQLiteObject] from the database. This will fail, if the object was not fetched -## from the database first. You can also use [method DbSet.erase] to remove an object from the -## database. -func delete() -> void: - assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!") - assert(_db, "delete(): This instance was not fetched from the database, or has not been added to a DbSet!") - var table := _tables[self.get_script()] - var primary_key = _get_primary_key(self.get_script()) - - assert(primary_key != "", "In order to delete data from the database, it must have a primary key!") - - if not exists(): - push_warning("Attempting to delete a record that doesn't exist!") - return - - _db.delete_rows(table.table_name, Condition.new().equal(primary_key, get(primary_key)).to_string()) - -func _to_string() -> String: - assert(_tables.has(self.get_script()), "Setup must be called first, before setting any column types!") - var table := _tables[self.get_script()] - var primary_key = _get_primary_key(self.get_script()) - var kname = self.get_script().get_global_name() - if primary_key != "": - return "<%s:%s:%s>" % [kname, table.table_name, get(primary_key)] - else: - return "<%s:%s:G-%s>" % [kname, table.table_name, get_instance_id()] diff --git a/addons/gdata_orm/sqlite_object.gd.uid b/addons/gdata_orm/sqlite_object.gd.uid deleted file mode 100644 index 241e202c..00000000 --- a/addons/gdata_orm/sqlite_object.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://uvaml64lmuws