<commit_before>using System;
using System.Collections;

using NHibernate.Util;

namespace NHibernate.SqlCommand
{
	/// <summary>
	/// Represents an <c>... in (...)</c> expression
	/// </summary>
	public class InFragment
	{
		private string columnName;
		private ArrayList values = new ArrayList();
		
		public InFragment AddValue(string value) 
		{
			values.Add(value);
			return this;

		}

		public InFragment SetColumn(string columnName) 
		{
			this.columnName = columnName;
			return this;
		}

		public InFragment SetColumn(string alias, string columnName) 
		{
			this.columnName = alias + StringHelper.Dot + columnName;
			return SetColumn( this.columnName );
		}

		public SqlString ToFragmentString() 
		{
			SqlStringBuilder buf = new SqlStringBuilder(values.Count + 5);
			buf.Add(columnName);
			if (values.Count > 1) 
			{
				bool allowNull = false;
				buf.Add(" in (");
				for(int i=0; i<values.Count; i++) 
				{
					if("null".Equals(values[i])) 
					{
						allowNull = true;
					}
					
					else 
					{
						buf.Add( (string)values[i] );
						if ( i<values.Count-1) buf.Add(StringHelper.CommaSpace);
					}
				}

				buf.Add(StringHelper.ClosedParen);
				if(allowNull) 
				{
					
					buf.Insert(0, " is null or ")
						.Insert(0, columnName)
						.Insert(0, StringHelper.OpenParen)
						.Add(StringHelper.ClosedParen);
				}
			} 
			else 
			{
				string value = values[0] as string;
				if ( "null".Equals(value) ) 
				{
					buf.Add(" is null");
				} 
				else 
				{
					buf.Add( "=" + values[0] );
				}
			}
			return buf.ToSqlString();
		}				<commit_msg>Fixed bug with "null" being a discriminator and the sql string generated having an extra comma at the end of the in list.<commit_after>using System;
using System.Collections;

using NHibernate.Util;

namespace NHibernate.SqlCommand
{
	/// <summary>
	/// Represents an <c>... in (...)</c> expression
	/// </summary>
	public class InFragment
	{
		private string columnName;
		private ArrayList values = new ArrayList();
		
		public InFragment AddValue(string value) 
		{
			values.Add(value);
			return this;

		}

		public InFragment SetColumn(string columnName) 
		{
			this.columnName = columnName;
			return this;
		}

		public InFragment SetColumn(string alias, string columnName) 
		{
			this.columnName = alias + StringHelper.Dot + columnName;
			return SetColumn( this.columnName );
		}

		public SqlString ToFragmentString() 
		{
			SqlStringBuilder buf = new SqlStringBuilder( values.Count * 5 );
			buf.Add( columnName );
			
			if( values.Count > 1 ) 
			{
				// is a comma needed before the value that's about to be added - it
				// defaults to false because we don't need a comma right away.
				bool commaNeeded = false;

				// if a "null" is in the list of values then we need to manipulate
				// the SqlString a little bit more at the end.
				bool allowNull = false;

				buf.Add( " in (" );
				for( int i=0; i<values.Count; i++ ) 
				{
					if("null".Equals(values[i])) 
					{
						allowNull = true;
					}
					else 
					{
						if( commaNeeded )
						{
							buf.Add( StringHelper.CommaSpace );
						}
						buf.Add( (string)values[i] );
						
						// a value has been added into the IN clause so the next
						// one needs a comma before it
						commaNeeded = true;
					}
				}

				buf.Add(StringHelper.ClosedParen);
				
				// if "null" is in the list of values then add to the beginning of the
				// SqlString "is null or [column] (" + [rest of sqlstring here] + ")"
				if( allowNull ) 
				{
					buf.Insert(0, " is null or ")
						.Insert(0, columnName)
						.Insert(0, StringHelper.OpenParen)
						.Add(StringHelper.ClosedParen);
				}
			} 
			else 
			{
				string value = values[0] as string;
				if ( "null".Equals(value) ) 
				{
					buf.Add(" is null");
				} 
				else 
				{
					buf.Add( "=" + values[0] );
				}
			}
			return buf.ToSqlString();
		}				
{'fraction_non_alphanumeric': 0.12030651340996168, 'fraction_numerical': 0.004342273307790549, 'mean_word_length': 2.3130287648054146, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7377683', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1262, 'n_words': 345}