summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2020-05-13 19:39:13 +0200
committerGitHub <noreply@github.com>2020-05-13 19:39:13 +0200
commit7048c66f61258b0110158bc8868a8e198f1a2a7c (patch)
treed9001eb6a4283779283d56b72371a3076e8ee65f
parent3eb6b77e754033d609e4819cda549d3927b9d1c9 (diff)
downloadwiki-7048c66f61258b0110158bc8868a8e198f1a2a7c.tar.gz
wiki-7048c66f61258b0110158bc8868a8e198f1a2a7c.tar.bz2
wiki-7048c66f61258b0110158bc8868a8e198f1a2a7c.zip
fix(SQL): Update files concerning SQL (#224)
-rw-r--r--_includes/azerothcore/sidebar.html3
-rw-r--r--docs/Dealing-with-SQL-files.md34
-rw-r--r--docs/SQL-Versioning.md9
-rw-r--r--docs/remove_add_flags.md49
4 files changed, 21 insertions, 74 deletions
diff --git a/_includes/azerothcore/sidebar.html b/_includes/azerothcore/sidebar.html
index 19fbfbd..ac08348 100644
--- a/_includes/azerothcore/sidebar.html
+++ b/_includes/azerothcore/sidebar.html
@@ -44,14 +44,13 @@
<li><a href="/wiki/Directory-Structure">Directory Structure</a></li>
<li><a href="/wiki/Coding-Standards">Coding Standards</a></li>
<li><a href="/wiki/Project-Versioning">Project Versioning</a></li>
- <li><a href="/wiki/SQL-Versioning">Sql Versioning</a></li>
+ <li><a href="/wiki/SQL-Versioning">SQL Versioning</a></li>
<li><a href ="/wiki/MySQLtypesC++">MySQL types (C++)</a></li>
<li><a href="/wiki/Hooks-Bash">Hooks Bash</a></li>
<li><a href="/wiki/Hooks-Cmake">Hooks Cmake</a></li>
<li><a href="/wiki/Create-a-new-Hook">Hooks C++</a></li>
<li><a href="/wiki/Database-Structure">Database Structure</a></li>
<li><a href="/wiki/CMake-options">CMake options</a></li>
- <li><a href="/wiki/remove_add_flags">Remove and Add database flags</a></li>
<li><a href="/wiki/Bit-and_bytes-tutorial">Bitwise operations</a></li>
</ul>
<b>Archive</b>
diff --git a/docs/Dealing-with-SQL-files.md b/docs/Dealing-with-SQL-files.md
index 69a97f2..ded1f9d 100644
--- a/docs/Dealing-with-SQL-files.md
+++ b/docs/Dealing-with-SQL-files.md
@@ -42,6 +42,22 @@ INSERT INTO `table_1` VALUES
(3000, ...);
```
+### DELETE
+
+Bad:
+
+```sql
+DELETE FROM `table_1` WHERE `entry` = 1000;
+DELETE FROM `table_1` WHERE `entry` = 2000;
+DELETE FROM `table_1` WHERE `entry` = 3000;
+```
+
+Good:
+
+```sql
+DELETE FROM `table_1` WHERE `entry` IN (1000, 2000, 3000);
+```
+
### UPDATE
Bad:
@@ -58,7 +74,7 @@ Good:
UPDATE `table_1` SET `field_1` = 'someValue' WHERE `entry` IN (1000, 2000, 3000);
```
-#### Flags
+### Flags
For flags (2^) columns, when you remove or add a flag, it is better not to override the existing value as flags are combined values.
@@ -77,22 +93,6 @@ UPDATE `table_1` SET `field_1` = `field_1` ^ 128 WHERE `entry` = 1000;
This way, you will make sure that your query will only affect that specific flag, leaving all the other flags unchanged.
-### DELETE
-
-Bad:
-
-```sql
-DELETE FROM `table_1` WHERE `entry` = 1000;
-DELETE FROM `table_1` WHERE `entry` = 2000;
-DELETE FROM `table_1` WHERE `entry` = 3000;
-```
-
-Good:
-
-```sql
-DELETE FROM `table_1` WHERE `entry` IN (1000, 2000, 3000);
-```
-
## How to create an sql update file
This kind of procedure is pretty simple and allow not only developers, but also testers, to avoid multiple import of the same queries.
diff --git a/docs/SQL-Versioning.md b/docs/SQL-Versioning.md
index ed6eaa6..e8aee90 100644
--- a/docs/SQL-Versioning.md
+++ b/docs/SQL-Versioning.md
@@ -12,13 +12,10 @@ In order to achieve this, we use a specific **convention for file names** and we
### File names
-The format we use to name sql update files is: **YYY_MM_DD_XX.sql**
+The file name should not be renamed and should be kept as the name `creat_sql.sh` has created for the file.
-where:
-- **YYYY** -> year
-- **MM** -> month
-- **DD** -> day
-- **XX** -> an incremental number starting from 00 to uniquely identify different files of the same day
+The file name will look like this:
+`rev_XXXXXXXXXXXXXXXXXXX`
### SQL Header
diff --git a/docs/remove_add_flags.md b/docs/remove_add_flags.md
deleted file mode 100644
index 76d0f7f..0000000
--- a/docs/remove_add_flags.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# Remove and add flags from database columns
-
-### Introduction
-
-Just like in C++, SQL also has bitwise operators that can be used to manipulate bitmasks.
-
-If you're not familiar with Bitwise operators I recommend you to go read [this article about bit operations.](https://github.com/azerothcore/wiki/blob/master/docs/Bit-and_bytes-tutorial.md)
-
-### Adding a flag to a bitmask
-
-Lets take ```creature_template.npcflag``` for this example. Our entry 12345 is a vendor and his flag is wrong. For us to fix him we need to
-set it to 128. Someone not familiar with bits and bytes would probably change the value of this npc flag
-like this:
-
-``` SQL
-UPDATE `creature_template` SET `npcflag` = 128 WHERE `entry` = 12345;
-```
-
-In reality, the best way to operate these flags would be to take his already existing flag, and add the bit 128 to the bitmask.
-We use the bitwise operator 'OR' to get the desired output.
-
-``` SQL
-UPDATE `creature_template` SET `npcflag` = `npcflag` | 128 WHERE `entry` = 12345;
-```
-
-This way, we garantee we don't lose the value that was set before by replacing it with a new one, we can also track the commit that
-made the npc 12345 a vendor and also eliminates the calculations that the developer needs to do to get his final value for the flag.
-
-### Removing a flag from a bitmask
-
-If you read the bit operations, you probably assume that to remove a value, we will use the operator 'AND' and utilize the symbol that
-inverts the bitmask '~'.
-
-If you wanted to make a creature not a vendor anymore, one would have to run the following query:
-
-``` SQL
-UPDATE `creature_template` SET `npcflag` = `npcflag` & ~(128) WHERE `entry` = 12345;
-```
-
-Graphically, this would mean that , if he had a gossip and was also a vendor, he would have flags 1 and 128 which means that it was 129.
-In other words, the bit operation would look like the following.
-
-``` C++
- AND OPERATION
-129 - 1 0 0 0 0 0 0 1
-~128 - 0 1 1 1 1 1 1 1
------------------------
-1 - 0 0 0 0 0 0 0 1
-```