Server name param in getDataSetByQuery

Hi:

In Servoy pre-6, you can use this:

databaseManager.getDataSetByQuery(controller.getServerName, [...])

But now, controller.getServerName is deprecated, so you have to use this:

databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), [...])

It’s annoying…

As with databaseManager.getFoundSet(), you could use a server name or a datasource as param, couldn’t you?

If what you mean is that if you could use a hardcoded DB name, yes you can.

Yeap, it’s rather a feature request :wink:

Log-Out,

The trouble is that with databaseManager.getFoundSet() you refer to a single table, so a datasource is appropriate.
But databaseManager.getDataSetByQuery() does not need a table, just the name of the server connection to use, so a datasource is too specific.

Rob

Hi Rob,

I think that is what he is asking. It’s just that we can’t get the servername that quickly anymore since controller.getServername() is deprecated.
My guess is that he wants it back :)

Personally, I also dislike this very much

databaseManager.getDataSourceServerName(controller.getDataSource())

I would like to either have controller.getServerName() back or have a DataSource javascript object that allows me to do controller.getDataSource().getServerName(). The current call is really ugly.

Why not allow:

databaseManager.getDataSetByQuery(controller.getDataSource())

Servoy should know, the servername, by giving the dataSource, I know, the dataSource also contains, the table, but that can be disregarded.

just my 2 cents…

Harjo:
Servoy should know, the servername, by giving the dataSource

I agree

Hi, I’m new here and really only exploring Servoy. I’ve come across this thread because I’m trying to use getDataSetByQuery()… and also found the code to get the ServerName a bit long-winded. So I did this:

function _getServerName()
{
	return databaseManager.getDataSourceServerName(currentcontroller.getDataSource());
}

Then I can write:

databaseManager.getDataSetByQuery(_getServerName(), ...)

Don’t know if this is a good idea, but what do you think :?:

Cheers,
foxproKing

Hi Gordon,

First of all welcome to the forum, I see this your first post.

Foxclever:

function _getServerName()

{
return databaseManager.getDataSourceServerName(currentcontroller.getDataSource());
}




Then I can write:

databaseManager.getDataSetByQuery(_getServerName(), …)

There are 2 limitations to your code.

  • This function is only in the scope of your .js file. You could make it a global method so you can call it from anywhere.
  • Using the currentcontroller will give you the controller of the top most form. So if you call this function from a form in a tabpanel then you get the parent controller and not the controller of the form you called it from.
    So to make such a function work you need to pass the form name or reference.

So your code could be like so:

/**
 * @param {String} formName
 */
function _getServerName(formName) {
   return databaseManager.getDataSourceServerName(forms[formName].controller.getDataSource());
}

Of course this still makes your code pretty verbose if you need to call this:

databaseManager.getDataSetByQuery(globals._getServerName(controller.getName()), ...)

Anyway, such a method would be a workaround. Preferably I (and I think many others) would like to see this supported in the core functionality of Servoy.

Did anyone filed a feature request yet in the support system ?

nope, if you put it in, I will vote! :-)