[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-schemafuzz] branch master updated: changed data stor
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-schemafuzz] branch master updated: changed data storage type to Object to handle timestamps. Tests pass . still getting synthax error on sql timestamp statements. change timestamp default format at the very begginning ? |
Date: |
Tue, 29 May 2018 16:46:37 +0200 |
This is an automated email from the git hooks/post-receive script.
erwan-ulrich pushed a commit to branch master
in repository schemafuzz.
The following commit(s) were added to refs/heads/master by this push:
new 72a0c0b changed data storage type to Object to handle timestamps.
Tests pass . still getting synthax error on sql timestamp statements. change
timestamp default format at the very begginning ?
72a0c0b is described below
commit 72a0c0bb75bd0af284c0f1bdab311b21cb4b5a3b
Author: Feideus <address@hidden>
AuthorDate: Tue May 29 16:46:29 2018 +0200
changed data storage type to Object to handle timestamps. Tests pass .
still getting synthax error on sql timestamp statements. change timestamp
default format at the very begginning ?
---
.../java/org/schemaspy/model/GenericTreeNode.java | 70 ++++++++++++----------
.../org/schemaspy/model/QueryResponseParser.java | 4 +-
src/main/java/org/schemaspy/model/Row.java | 20 +++----
.../java/org/schemaspy/model/SingleChange.java | 16 ++---
.../org/schemaspy/model/GenericTreeNodeTest.java | 8 ++-
5 files changed, 64 insertions(+), 54 deletions(-)
diff --git a/src/main/java/org/schemaspy/model/GenericTreeNode.java
b/src/main/java/org/schemaspy/model/GenericTreeNode.java
index f974463..3ddd9fd 100644
--- a/src/main/java/org/schemaspy/model/GenericTreeNode.java
+++ b/src/main/java/org/schemaspy/model/GenericTreeNode.java
@@ -216,7 +216,7 @@ public class GenericTreeNode {
ArrayList<SingleChange> possibilities = new ArrayList<SingleChange>();
//TRYING TO DISCOVER RAW POSSIBILITIES
- for (Map.Entry<String, String> content :
initial_state_row.getContent().entrySet())
+ for (Map.Entry<String, Object> content :
initial_state_row.getContent().entrySet())
{
try
{
@@ -240,7 +240,7 @@ public class GenericTreeNode {
return possibilities;
}
- public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, String column_value,GenericTreeNode rootMutation) throws Exception
//listing of the mutation possibilities on the specified row
+ public ArrayList<SingleChange> discoverFieldPossibilities(TableColumn
tableColumn, Object column_value,GenericTreeNode rootMutation) throws Exception
//listing of the mutation possibilities on the specified row
{
ArrayList<SingleChange> oneChange = new ArrayList<SingleChange>();
@@ -252,7 +252,7 @@ public class GenericTreeNode {
case "smallint":
case "integer":
case "int2":
- int tmp =
Integer.parseInt(rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()));
+ int tmp =
Integer.parseInt(rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()).toString());
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(tmp++)));
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(32767)));
oneChange.add(new SingleChange(tableColumn, this,
column_value, Integer.toString(1)));
@@ -262,15 +262,15 @@ public class GenericTreeNode {
case "character varying":
case "varchar":
if (rootMutation == null) {
- char tmp2 = column_value.charAt(0);
- oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2++) + column_value.substring(1))));
- oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2--) + column_value.substring(1))));
+ char tmp2 = column_value.toString().charAt(0);
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2++) +
column_value.toString().substring(1))));
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(tmp2--) +
column_value.toString().substring(1))));
} else {
- char tmp2 = (char)
rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()).charAt(0);
+ char tmp2 = (char)
rootMutation.getInitial_state_row().getContent().get(tableColumn.getName()).toString().charAt(0);
char nextChar = (char) (tmp2 + 1);
char prevChar = (char) (tmp2 - 1);
- oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(nextChar) + column_value.substring(1))));
- oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(prevChar) + column_value.substring(1))));
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(nextChar) +
column_value.toString().substring(1))));
+ oneChange.add(new SingleChange(tableColumn, this,
column_value, (Character.toString(prevChar) +
column_value.toString().substring(1))));
}
break;
@@ -281,7 +281,7 @@ public class GenericTreeNode {
oneChange.add(new SingleChange(tableColumn, this,
column_value, "f"));
break;
- case "timestamp":
+ /*case "timestamp":
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd
hh:mm:ss");
Calendar cal = Calendar.getInstance();
@@ -300,7 +300,7 @@ public class GenericTreeNode {
break;
- /*case 6: typeName = "June";
+ case 6: typeName = "June";
break;
case 7: typeName = "July";
break;
@@ -369,59 +369,63 @@ public class GenericTreeNode {
if (undo)
{
- if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar") ||
chosenChange.getParentTableColumn().getTypeName().equals("bool"))
- theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getOldValue() + "', ";
+ if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar")
+ ||
chosenChange.getParentTableColumn().getTypeName().equals("bool")
+ ||
chosenChange.getParentTableColumn().getTypeName().equals("timestamp"))
+ theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getOldValue().toString() + "', ";
else
- theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + " = " +
chosenChange.getOldValue() + ", ";
+ theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + " = " +
chosenChange.getOldValue().toString() + ", ";
}
else
{
- if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar") ||
chosenChange.getParentTableColumn().getTypeName().equals("bool"))
- theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getNewValue() + "', ";
+ if
(chosenChange.getParentTableColumn().getTypeName().equals("varchar")
+ ||
chosenChange.getParentTableColumn().getTypeName().equals("bool")
+ ||
chosenChange.getParentTableColumn().getTypeName().equals("timestamp"))
+ theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "='" +
chosenChange.getNewValue().toString() + "', ";
else
- theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "=" +
chosenChange.getNewValue() + ", ";
+ theQuery = "UPDATE " +
initial_state_row.getParentTable().getName() + " SET " +
chosenChange.getParentTableColumn().getName() + "=" +
chosenChange.getNewValue().toString() + ", ";
}
- for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet())
+ for (Map.Entry<String, Object> entry :
initial_state_row.getContent().entrySet())
{
if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName()))
{
- if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool"))
- theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue() + "', ");
+ if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
+
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool")
||
+
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("timestamp"))
+ theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue().toString() + "', ");
else
- theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue() + ", ");
+ theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue().toString() + ", ");
}
}
theQuery = theQuery.substring(0, theQuery.lastIndexOf(","));
theQuery = theQuery + " WHERE ";
- // USING ALL VALUES TO TRIANGULATE THE ROW TO UPDATE (no primary key)
- if (initial_state_row.getParentTable().getPrimaryColumns().isEmpty())
- {
- for (Map.Entry<String, String> entry :
initial_state_row.getContent().entrySet())
+
+ for (Map.Entry<String, Object> entry :
initial_state_row.getContent().entrySet())
{
if
(!entry.getKey().equals(chosenChange.getParentTableColumn().getName()))
{
- if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool"))
- theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue() + "' AND ");
+ if
(chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("varchar")
||
+
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("bool")
||
+
chosenChange.getParentTableColumn().getTable().getColumn(entry.getKey()).getTypeName().equals("timestamp"))
+ theQuery = theQuery + (entry.getKey() + "='" +
entry.getValue().toString() + "' AND ");
else
- theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue() + " AND ");
+ theQuery = theQuery + (entry.getKey() + "=" +
entry.getValue().toString() + " AND ");
}
else
{
if (undo)
- theQuery = theQuery + (entry.getKey() + "='" +
chosenChange.getNewValue() + "' AND ");
+ theQuery = theQuery + (entry.getKey() + "='" +
chosenChange.getNewValue().toString() + "' AND ");
else
- theQuery = theQuery + (entry.getKey() + "='" +
chosenChange.getOldValue() + "' AND ");
+ theQuery = theQuery + (entry.getKey() + "='" +
chosenChange.getOldValue().toString() + "' AND ");
}
}
theQuery = theQuery.substring(0, theQuery.lastIndexOf(" AND "));
- }
- else
- theQuery = theQuery + (" " +
initial_state_row.getParentTable().getPrimaryColumns().get(0).getName() + "=" +
initial_state_row.getValueOfColumn(initial_state_row.getParentTable().getPrimaryColumns().get(0).getName()));
System.out.println("build query ! "+theQuery); //uncomment to see
built request;
+
return theQuery;
}
diff --git a/src/main/java/org/schemaspy/model/QueryResponseParser.java
b/src/main/java/org/schemaspy/model/QueryResponseParser.java
index ddbe655..e24b825 100644
--- a/src/main/java/org/schemaspy/model/QueryResponseParser.java
+++ b/src/main/java/org/schemaspy/model/QueryResponseParser.java
@@ -56,10 +56,12 @@ public class QueryResponseParser
while(resultOfQuery.next())
{
- HashMap<String,String> mapOfTheRow = new HashMap<String,String>();
+ HashMap<String,Object> mapOfTheRow = new HashMap();
for(i = 1; i <= resultMeta.getColumnCount();i++)
{
+ if(resultMeta.getColumnTypeName(i).equals("timestamp"))
+
mapOfTheRow.put(resultMeta.getColumnName(i),resultOfQuery.getTimestamp(i));
mapOfTheRow.put(resultMeta.getColumnName(i),
resultOfQuery.getString(i));
}
diff --git a/src/main/java/org/schemaspy/model/Row.java
b/src/main/java/org/schemaspy/model/Row.java
index 59890e3..53f7d80 100644
--- a/src/main/java/org/schemaspy/model/Row.java
+++ b/src/main/java/org/schemaspy/model/Row.java
@@ -33,17 +33,17 @@ import java.util.*;
public class Row
{
private Table parentTable;
- private HashMap<String,String> content;
+ private HashMap<String,Object> content;
private Integer nbKeys;
public Row() {
- this.content = new HashMap<String,String>();
+ this.content = new HashMap<String,Object>();
}
- public Row(Table parentTable, HashMap<String,String> content, Integer
nbKeys)
+ public Row(Table parentTable, HashMap<String,Object> content, Integer
nbKeys)
{
this.parentTable = parentTable;
- this.content = new HashMap<String,String>();
+ this.content = new HashMap<String,Object>();
this.content = content;
this.nbKeys = nbKeys;
}
@@ -53,11 +53,11 @@ public class Row
return this.parentTable;
}
- public HashMap<String,String> getContent() {
+ public HashMap<String,Object> getContent() {
return content;
}
- public void setContent(HashMap<String,String> content) {
+ public void setContent(HashMap<String,Object> content) {
this.content = content;
}
@@ -66,12 +66,12 @@ public class Row
return nbKeys;
}
- public String getValueOfColumn(String columnName)
+ public Object getValueOfColumn(String columnName)
{
return content.get(columnName);
}
- public void setValueOfColumn(String columnName, String newVal)
+ public void setValueOfColumn(String columnName, Object newVal)
{
this.getContent().replace(columnName, newVal);
}
@@ -92,7 +92,7 @@ public class Row
if(content.size() != initial_state_row.getContent().size())
return false;
- for(Map.Entry<String,String> entry : content.entrySet())
+ for(Map.Entry<String,Object> entry : content.entrySet())
{
if(!initial_state_row.getContent().containsKey(entry.getKey()))
return false;
@@ -105,7 +105,7 @@ public class Row
public Row clone()
{
- HashMap<String,String> clonedMap = (HashMap<String,String>)
this.content.clone();
+ HashMap<String,Object> clonedMap = (HashMap<String,Object>)
this.content.clone();
Row res = new Row(this.parentTable,clonedMap,this.content.keySet().size());
return res;
diff --git a/src/main/java/org/schemaspy/model/SingleChange.java
b/src/main/java/org/schemaspy/model/SingleChange.java
index 6c4cd23..b0be256 100644
--- a/src/main/java/org/schemaspy/model/SingleChange.java
+++ b/src/main/java/org/schemaspy/model/SingleChange.java
@@ -6,11 +6,11 @@ public class SingleChange
{
private GenericTreeNode attachedToMutation;
private TableColumn parentTableColumn;
- private String oldValue;
- private String newValue;
+ private Object oldValue;
+ private Object newValue;
- public SingleChange(TableColumn parentColumn ,GenericTreeNode
attachedToMutation, String oldValue, String newValue)
+ public SingleChange(TableColumn parentColumn ,GenericTreeNode
attachedToMutation, Object oldValue, Object newValue)
{
this.attachedToMutation = attachedToMutation;
this.parentTableColumn = parentColumn;
@@ -23,15 +23,15 @@ public class SingleChange
switch (parentTableColumn.getTypeName())
{
case "serial":
- if(Integer.parseInt(newValue) <
Math.pow(2,parentTableColumn.getLength()))
+ if(Integer.parseInt(newValue.toString()) <
Math.pow(2,parentTableColumn.getLength()))
return true;
return false;
case "numeric":
- if(Integer.parseInt(newValue) <
Math.pow(2,parentTableColumn.getLength()))
+ if(Integer.parseInt(newValue.toString()) <
Math.pow(2,parentTableColumn.getLength()))
return true;
return false;
case "int2":
- if(Integer.parseInt(newValue) <= 32767)
+ if(Integer.parseInt(newValue.toString()) <= 32767)
return true;
return false;
default:
@@ -45,12 +45,12 @@ public class SingleChange
return "\n[SG - attachedToMutation :
"+this.getAttachedToMutation().getId()+"| OV :"+oldValue+" | NV :"+newValue+"
]\n";
}
- public String getOldValue()
+ public Object getOldValue()
{
return oldValue;
}
- public String getNewValue()
+ public Object getNewValue()
{
return newValue;
}
diff --git a/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
b/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
index a2fde19..39fd062 100644
--- a/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
+++ b/src/test/java/org/schemaspy/model/GenericTreeNodeTest.java
@@ -102,10 +102,14 @@ public class GenericTreeNodeTest {
}
@Test
- public void singleChangeAttachedMutatationShouldMatch() // Not very Usefull
+ public void singleChangeAttachedMutationShouldMatch() // Not very Usefull
{
GenericTreeNode gtn1 = new GenericTreeNode(null,1,null,null);
- SingleChange sg1 = new SingleChange(null,null,"1","2");
+ String s1 = "1";
+ Object so1 = s1;
+ String s2 = "2";
+ Object so2 = s2;
+ SingleChange sg1 = new SingleChange(null,null,so1,so2);
gtn1.setChosenChange(sg1);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [taler-schemafuzz] branch master updated: changed data storage type to Object to handle timestamps. Tests pass . still getting synthax error on sql timestamp statements. change timestamp default format at the very begginning ?,
gnunet <=