Subsonic3 & GUIDs - subsonic

I have a table with a PrimaryKey that is set as uniqueidentifier (GUID) and it's autopopulated using the newsequentialid() function from sql server 2008... When I insert a row manually, everything works as normal. But when I insert the record using the subsonic class and the repository the GUID column defaults to all zero's and the database will enter that value. I need it to NOT do this and use the default value of the column... anyone else able to get around this issue?

This was fixed in 2.0.2 for SQL 2005 - I'm wondering if there's an issue with SQL 2008. What version are you using? I'm thinking this might not have been covered in 3.x just yet.

Related

JetBrains DataGrip set field value to now()

I'm using DataGrip inside PhpStorm to access MySQL database. From time to time I need to update datetime fields with current time. For example TablePlus has the option to set field value to now() and on save it populates it with current datetime. It would be nice to have something similar on DataGrip as it is my primary database editor and it is really annoying setting time by hand.
Maybe someone has a solution for this?
There is no way to achieve this at the moment. Here are 2 related feature requests on our tracker, please follow and vote: 'add NOW to datepicker', 'using functions in table editor'

Can I use any other column name than id in my xamarin forms app?

As the title suggest, I was wondering if it was possible to use any other column name for the index than id?
The documentation for creating a Mobile Backend in Azure and Xamarin Forms app stipulates that the index column must be id all lower case for the API to return data. What if your index column is called something else, for example idx_index.
My issue is that my database already exists and there are a lot of tables. I'd like to avoid having to rename the index columns in the database if I can.
Is there anything I can do that would help me avoid this problem or does it look like I'll need to rename my columns to id?
No - you cannot use any other name other than id. This is in-built into the SDK and you would need to alter both the server and client SDKs (and compile new ones) to support something else. This is a non-trivial update.
Since my database already existed all the column naming was set. To get around this problem when it came to Azure and it's expectation of a column called id I simply cast the column names in some custom views which were specific to my mobile app. For example:
SELECT index_idx as id,
name,
location
FROM mytable

Can you make columns optional for SQL Insert Row in Azure Logic Apps?

I am using the Logic App designer on Azure. Added "SQL Azure - Insert Row" as an Action, it prompts me to insert values for the columns but all the columns are marked as required and it doesn't save the changes/sequence if a value is not entered there.
Is there anyway of bypassing this or making the columns optional?
I tried this previously, there was no way to make the columns optional but i figured a workaround.
First, in the designer put any value, then open Code view and look for the columns you don't need and just delete it from the JSON schema and hit save :)
that should do it for you, but next time you open in designer and try to edit you have to do this again.
let me know if it helps
Edited
I added a screenshot of the steps that i made while trying to replicate this. (note that your database schema should handle these null values for the columns, in my case the Guid had a default value of newid() and the other column allowed nulls). You always pass null to the columns, not passing values at all might make sense for columns that has values computed or has default values (like newid() uniqueidentifier or getdate() for created/modified time)

Azure SQL Database Management Portal - default column value

In the Azure SQL Database Management portal I was trying to add a new column to an existing table that contains rows.
I added the default value - 0 - thinking that it would add the default to existing rows and therefore setting the column to 'Is Required' (not nullable) would be OK. However, when I tried to save, I got the error:
ALTER TABLE only allows columns to be added that can contain nulls, or
have a DEFAULT definition specified, or ...
I could however execute the following SQL statement:
ALTER TABLE Sales
ADD Purchase int NOT NULL
CONSTRAINT PurchaseDefault DEFAULT 0
When I looked at the table again in azure, I saw that the Default value had ((0))
So, on the next column that I had to add I tried putting the default in double brackets ((0)), but that did not work either.
So, I went to SQL Server Management Studio 2012 on my dev machine. Here I can add a new column with 0 in the 'Default Value Or Binding' option. This worked. Interestingly, when I went back the 0 was now ((0)).
So, my questions are:-
How is the Default Value column in Azure different from adding a default constraint?
Why is this OK in SQL Server 2012, but not Azure?
What are the (()) about? I tried googling for various combinations of 'double brackets/braces default constraints', but came up empty.
I think what you met with were correct. I'm not a DBA but let me try to explain something I know for now.
If you are using SQL Server Management Studio (SSMS) to specify default value, it will be wrapped by brackets automatically. If your default value is a static value, for example zero, it will be ((0)), if it's some calculation value for example the current date/time, it will be (GETDATE()). But I'm not pretty sure why it must be wrapped by (double) brackets
I guess there are some existing records in your SQL Azure. Your understanding of ... it would add the default to existing rows ... is not correct. Default value will NOT affect existing records. It will just set the value to default if you don't specify explicitly. This is the reason why your got error when you applied your changes in SQL Azure. I think you need to run a script to set the default value to this columns for all existing records then apply this change. Something like UPDATE [Your_Table] SET [Purchase] = 0 WHERE [Purchase] IS NULL.
Hope this helps

Is Accreditation a reserved word?

Using Subsonic 2.2 latest SVN.
SQL Server 2008 table has a column called Accreditation
The Subsonic generated property for this column is named AccreditationX
Can anybody tell me why ?
Going to guess it's the same name as your table...

Resources