Wakanda MySQL TEXT data type - wakanda

Can't get data from MySQL field with data type "text".
It just return empty value, for other string type (char, varchar) it's returning a value as expected.
Any help would be highly appreciated,
Thanks.

We've dug into this, and indeed there is a bug on the Pro Connector:
- The Text type is not properly managed
We' ll fix this asap.
In the meantime, you could use the following workaround (it's not perfect however) -
Workaround:
To manage specifically the text type, for now you could use the Mysql Wakanda driver. When using it text type are handled as blob type you might parse as string.
var sql = require('waf-sql');
var params = {
hostname: '192.168.XX.XX',
port: xx,
user: 'xx',
password: 'xx',
database: 'xx',
ssl: false,
dbType: 'mysql'
};
var session = sql.connect(parms);
var query = "select txt from TextType";
var res = session.execute(query);
var rows = res.getAllRows();
rows[0].txt.toString()
It's not as advanced as the Pro Connector but it allows you to retrieve your elements.
EDIT :
The bug has been fixed and will be included in the next major Wakanda version. I'll keep u posted here when the release date is defined.
BR
Fred
Wakanda Team

Related

DynamoDB asks for Partition Key of main table when querying GSI

So, the thing is, I'm trying to query a GSI table on DynamoDB and get a really weird behaviour.
The main table schema is as follows
- Partition key: test_id (string)
- Sort key: version (string)
- Other attributes (createdAt, tags, etc)
I want to obtain every entry that has a sort_key equal to v0_test WITHOUT filtering by partition key. To do this and avoid a full scan I created a GSI (Global Secondary Index) as follows:
- Partition key: version (string)
- Sort key: createdAt (number)
- Other attributes (test_id, tags, etc)
When querying this from AWS console I can query for every partition key equal to v0_test and I get the expected results, but when I query from inside a lambda function (runtime: nodejs16.x) I get an error.
The code for the query is as follows:
const dynamoDb = new AWS.DynamoDB.DocumentClient();
let params = {
TableName: dynamoTable,
IndexName: dynamoTableIndex ,
KeyConditionExpression: 'version = :v0 AND createdAt BETWEEN :tLower AND :tUpper',
ExpressionAttributeValues: {
':v0': 'v0_test',
':tUpper': Math.floor(Date.now() / 1000).toString(),
':tLower': '0'
}
};
let result = await dynamoDb.query(params).promise();
console.log("Success", result);
And the error I get is
ERROR ValidationException: Query condition missed key schema element: test_id
As you can see it's asking for the partition key for the main table.
Things I've tried:
Using AWS.DynamoDB instead of AWS.DynamoDB.DocumentClient. Same error
Changing version for test_id in the query. Got ERROR ValidationException: Query condition missed key schema element: version
Sending both version and test_id on KeyConditionExpression. Got the following error:ERROR ValidationException: KeyConditionExpressions must only contain one condition per key
New Dynamo table, new GSI. Same errors
I wasn't expecting that at all. It's my first time using DynamoDB but as I understand it the idea behind GSI's (or one of them) is to be able to query a DynamoDB table by other attribute than it's main partition key without having to do a full scan.
Any help appreciated and if you need more details just ask! It's my first time asking on StackOverflow too so I'm sure I'll miss something.
EDIT
Tested the suggested solution and got an error suggesting that the schema was wrong, which was a new error and got me thinking, so I tried specifying the ExpressionAttributeNames and it WORKED!.
I created the request as follows using DocumentClient:
const dynamoDb = new AWS.DynamoDB.DocumentClient();
let params = {
TableName: 'CLASSIFIER_TESTS_DEV_us-east-1',
IndexName: 'version-createdAt-index',
KeyConditionExpression: '#versionAttr = :version AND #ca BETWEEN :tLower AND :tUpper',
ExpressionAttributeNames: {
"#versionAttr": "version",
"#ca": "createdAt"
},
ExpressionAttributeValues: {
":version": "v0_test",
":tUpper": Date.now(),
":tLower": 0
}
};
let result = await dynamoDb.query(params).promise();
Thanks everyone!
I still think that it should have worked the way I did it the first time as that's the way everyone does it on tutorials/examples/documentation, but oh well, got it working and that's what matters for now.
This should not be an issue. I would suggest the following:
Test locally, have your DynamoDB API call run from your local machine, this will ensure that no issues are being caused by Lambda invocations
Hard code your TableName and IndexName as strings in your parameters.
If the above is still causing an issue, try the same logic but this time a Query from the base table.
Let me know if you still face issue after that, happy to help.

Wakanda Datastore - Find and Replace?

I've got a lot of values in a legacy Wakanda datastore which I need to update to some new values. Is there a curl-like command in the wakanda data browser page that can be used to do a mass find-and-replace in a table?
If your dataclass is called MyDataClass and the attribute you want to update is myAttribute you can use the following server-side script :
var newValue = "new value";
ds.MyDataClass.all().forEach(function(entity){
entity.myAttribute = newValue;
entity.save();
});
You can also use a transaction if you want to commit or rollback the whole operation
I don't think there is a way to do a mass of find/replace in the dataBrowser,
But I suggest you to use a query in the server side that search the records with the value you need to replace, and then a loop on this collection to set the new values
As mentioned in other answers, you are likely best to loop over a collection. There is no concept of a mass replace in Wakanda like you see in many other databases.
var myCollection = ds.DataClassName.query("attributeName == :1", "valueToFind");
myCollection.forEach(function(e){
e.attributeName = "newValue";
e.save();
});
So a fake "person" data type might look like this:
var blankFirsts = ds.Person.query("firstname == :1", "");
blankFirsts.forEach(function(person){
person.firstname = "no name";
person.save();
});

Visual Studio 2013 TableAdapter Config Wizard for Oracle

I'm a new user to setting up a query using the TableAdapter Config Wizard. I'm trying to run a simple query, and I thought it should look like this:
select id, name, val
from tableA
where name = #parm1 and val = #parm2
This does not work. How do I write the query and pass parameters using Oracle?
In Oracle, your parameters need to be prefixed with a colon, not an at sign:
select id, name, val
from tableA
where name = :parm1 and val = :parm2
On a related note, when you instantiate the parameters, unlike Sybase/SQL Server, you actually leave the identifier off of the parameter name:
OracleCommand cmd = new OracleCommand(sql, connection);
cmd.Parameters.Add(new OracleParameter("parm1", OracleDataType.Varchar));
I may have the Data Type enum slightly off, but you get the idea.

How can I change the column name of an existing Class in the Parse.com Web Browser interface?

I couldn't find a way to change a column name, for a column I just created, either the browser interface or via an API call. It looks like all object-related API calls manipulate instances, not the class definition itself?
Anyone know if this is possible, without having to delete and re-create the column?
This is how I did it in python:
import json,httplib,urllib
connection = httplib.HTTPSConnection('api.parse.com', 443)
params = urllib.urlencode({"limit":1000})
connection.connect()
connection.request('GET', '/1/classes/Object?%s' % params, '', {
"X-Parse-Application-Id": "yourID",
"X-Parse-REST-API-Key": "yourKey"
})
result = json.loads(connection.getresponse().read())
objects = result['results']
for object in objects:
connection = httplib.HTTPSConnection('api.parse.com', 443)
connection.connect()
objectId = object['objectId']
objectData = object['data']
connection.request('PUT', ('/1/classes/Object/%s' % objectId), json.dumps({
"clonedData": objectData
}), {
"X-Parse-Application-Id": "yourID",
"X-Parse-REST-API-Key": "yourKEY",
"Content-Type": "application/json"
})
This is not optimized - you can batch 50 of the processes together at once, but since I'm just running it once I didn't do that. Also since there is a 1000 query limit from parse, you will need to do run the load multiple times with a skip parameter like
params = urllib.urlencode({"limit":1000, "skip":1000})
From this Parse forum answer : https://www.parse.com/questions/how-can-i-rename-a-column
Columns cannot be renamed. This is to avoid breaking an existing app.
If your app is still under development, you can just query for all the
objects in your class and copy the value of the old column to the new
column. The REST API is very useful for this. You may them drop the
old column in the Data Browser
Hope it helps
Yes, it's not a feature provided by Parse (yet). But there are some third party API management tools that you can use to rename the fields in the response. One free tool is called apibond.com
It's a work around, but I hope it helps

Oracle db gives ORA-01722 for seemingly NO REASON AT ALL

I'm trying to use an Oracle database with ado.net, and it is proving a painful experience. I use Oracle Client (Oracle.Data namespaces).
The following query runs fine from a query window:
UPDATE PRINT_ARGUMENT
SET VALUE = 'Started'
WHERE REQUEST_ID = 1 AND KEYWORD = '{7D066C95-D4D8-441b-AC26-0F4C292A2BE3}'
When I create an OracleCommand however the same thing blows up with ORA-01722. I can't figure out why.
var cmd = cnx.CreateCommand();
cmd.CommandText = #"
UPDATE PRINT_ARGUMENT
SET VALUE = :value
WHERE REQUEST_ID = :requestID AND KEYWORD = :key";
cmd.Parameters.Add(new OracleParameter("requestID", (long)1);
cmd.Parameters.Add(new OracleParameter("key", "{7D066C95-D4D8-441b-AC26-0F4C292A2BE3}");
cmd.Parameters.Add(new OracleParameter("value", "Started");
cnx.Open();
try { int affected = cnx.ExecuteNonQuery(); }
finally { cnx.Close(); }
When I inspect the command in the debugger, the parameters appear to have mapped to the correct types: requestID has OracleDbType.Int64, key and value are both OracleDbType.Varchar2. The values of the parameters are also correct.
This gets even stranger when you consider that I have other queries that operate on the exact same columns (requestID, keyword, value) using the same approach - and they work without a hiccup.
For the record, the column types are requestID NUMBER(10,0); key VARCHAR2(30); value VARCHAR2(2000).
According to Oracle, ORA-01722 'invalid number' means a string failed to convert to a number. Neither of my string values are numbers, neither of the OracleParameters created for them are numeric, and neither
By default, ODP.NET binds parameters by position, not by name, even if they have actual names in the SQL (instead of just ?). So, you are actually binding requestID to :value, key to :requestID and value to :key.
Correct the order of cmd.Parameters.Add in your code, or use BindByName to tell ODP.NET to use the parameter names.
Since you are using named parameters, you have to tell the Oracle client about it. Otherwise your parameters are mixed up (key is assigned to :value):
OracleParameter parameter = new OracleParameter("requestID", (long)1);
parameter.BindByName = true;
cmd.Parameters.Add(parameter);
It's a strange and unexpected behavior, but that's how it is.

Resources